Lua
natiny.input.get_key_pressed(key) -> boolean
Returns true only on the frame when the specified key was first pressed down.
Parameters
| Name |
Type |
Description |
key |
number |
Key code - a natiny.input.KEY_* constant, e.g. natiny.input.KEY_W |
Returns
| Type |
Description |
boolean |
true on the frame the key was pressed, false otherwise |
Example
Lua
if natiny.input.get_key_pressed(natiny.input.KEY_SPACE) then
jump()
end
Notes
- Returns
true for the frame that consumes a released-to-pressed transition.
- Key constants are listed in Key codes.