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:

  1. .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:

  1. on_press(function) – calls a function when a key is pressed
  2. on_release(function) – calls a function when a key is released