Keyboard event in pyleap
Keys that we can use to trigger an action:
➢ Letters – A, B, C, D, E, F, G, . . .
➢ Numbers – _1, _2, _3, _4, . . . (since we cannot start a variable name by numbers we have to use underscore)
➢ Arrow keys – LEFT, RIGHT, UP, DOWN
➢ Function keys – F1, F2, F3, . . .
➢ Switch keys – LSHIFT, RSHIFT, LCTRL, RCTRL, CAPSLOCK, LMETA, RMETA, LALT, RALT, LWINDOWS, RWINDOWS, LCOMMAND, RCOMMAND, LOPTION, ROPTION
➢ Number zone – NUM_0, NUM_1, NUM_2 …
Attribute:
- .pressed – returns true if the key specified is pressed.
example: key.A.pressed
This attribute is useful when we want our objects/Sprites to move continuously, especially for games.
Method:
- on_press(function) – calls a function when a key is pressed
- on_release(function) – calls a function when a key is released