2021-01-14 18:19:22 +00:00
|
|
|
---
|
|
|
|
module: [kind=event] key_up
|
|
|
|
see: keys For a lookup table of the given keys.
|
|
|
|
---
|
|
|
|
|
2023-03-15 21:52:13 +00:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: 2021 The CC: Tweaked Developers
|
|
|
|
|
2023-10-11 07:00:07 +00:00
|
|
|
SPDX-License-Identifier: MPL-2.0
|
2023-03-15 21:52:13 +00:00
|
|
|
-->
|
|
|
|
|
2021-01-14 18:19:22 +00:00
|
|
|
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, <kbd>F1</kbd> is 290). This value may vary between versions and
|
2023-08-24 09:48:30 +00:00
|
|
|
so it is recommended to use the constants in the [`keys`] API rather than hard coding numeric values.
|
2021-01-14 18:19:22 +00:00
|
|
|
|
|
|
|
## Return values
|
2023-08-24 09:48:30 +00:00
|
|
|
1. [`string`]: The event name.
|
|
|
|
2. [`number`]: The numerical key value of the key pressed.
|
2021-01-14 18:19:22 +00:00
|
|
|
|
|
|
|
## Example
|
2023-08-24 09:48:30 +00:00
|
|
|
Prints each key released on the keyboard whenever a [`key_up`] event is fired.
|
2021-01-14 18:19:22 +00:00
|
|
|
|
|
|
|
```lua
|
|
|
|
while true do
|
|
|
|
local event, key = os.pullEvent("key_up")
|
|
|
|
local name = keys.getName(key) or "unknown key"
|
|
|
|
print(name .. " was released.")
|
|
|
|
end
|
|
|
|
```
|