1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-11-17 23:34:51 +00:00
CC-Tweaked/doc/events/key_up.md
Jonathan Coates 440fca6535
Relicense a couple of more files
We've got in touch with Brady, so can now do the last of the docs \o/!

Also pick up a couple of stragglers that I'd missed from before.
2023-10-11 08:00:07 +01:00

858 B

module: [kind=event] key_up see: keys For a lookup table of the given keys.

Fired whenever a key is released (or the terminal is closed while a key was being pressed).

This event returns a numerical "key code" (for instance, F1 is 290). This value may vary between versions and so it is recommended to use the constants in the [keys] API rather than hard coding numeric values.

Return values

  1. [string]: The event name.
  2. [number]: The numerical key value of the key pressed.

Example

Prints each key released on the keyboard whenever a [key_up] event is fired.

while true do
  local event, key = os.pullEvent("key_up")
  local name = keys.getName(key) or "unknown key"
  print(name .. " was released.")
end