Keys - JakeTurner616/pygame-lua-bindings GitHub Wiki

get_focused()

Check if the Pygame window is currently focused.

Returns::

  • True if the Pygame window is focused, False otherwise.

Maps to:

  • pygame.key.get_focused(): This function checks if the Pygame window is currently focused.

get_pressed()

Get the state of all keyboard keys.

Returns:: A Lua table containing the state of all keyboard keys, where the keys are the key codes and the values are True if the key is pressed, False otherwise.

Maps to:

  • pygame.key.get_pressed(): This function returns the state of all keyboard keys as a list.

get_mods()

Get the state of modifier keys (Shift, Ctrl, Alt, etc.).

Returns:: An integer representing the state of modifier keys.

Maps to:

  • pygame.key.get_mods(): This function returns an integer representing the state of modifier keys.

set_mods(mods)

Set the state of modifier keys (Shift, Ctrl, Alt, etc.).

Parameters::

  • mods: An integer representing the new state of modifier keys.

Maps to:

  • pygame.key.set_mods(mods): This function sets the state of modifier keys.

set_repeat(delay=None, interval=None)

Set keyboard key repeat behavior.

Parameters::

  • delay: The delay in milliseconds before the first repeated key event. If None, the key repeat is disabled.
  • interval: The interval in milliseconds between repeated key events.

Maps to:

  • pygame.key.set_repeat(delay, interval): This function sets the keyboard key repeat behavior.

get_repeat()

Get the current keyboard key repeat delay and interval.

Returns:: A tuple containing the delay and interval in milliseconds.

Maps to:

  • pygame.key.get_repeat(): This function returns the current keyboard key repeat delay and interval.

key_name(key, use_compat=True)

Get the name of a key given its key code.

Parameters::

  • key: The key code.
  • use_compat: Whether to use the compatibility key names. Default is True.

Returns:: The name of the key.

Maps to:

  • pygame.key.name(key, use_compat): This function returns the name of a key given its key code.

key_code(name)

Get the key code of a key given its name.

Parameters::

  • name: The name of the key.

Returns:: The key code of the key.

Maps to:

  • pygame.key.key_code(name): This function returns the key code of a key given its name.

start_text_input()

Start text input mode.

Maps to:

  • pygame.key.start_text_input(): This function starts text input mode.

stop_text_input()

Stop text input mode.

Maps to:

  • pygame.key.stop_text_input(): This function stops text input mode.

set_text_input_rect(rect)

Set the rectangle where text input will be captured.

Parameters::

  • rect: A tuple or list containing the (x, y, width, height) of the rectangle.

Maps to:

  • pygame.key.set_text_input_rect(rect): This function sets the rectangle where text input will be captured.

Key constants

  • K_BACKSPACE: Backspace key
  • K_TAB: Tab key
  • K_CLEAR: Clear key
  • K_RETURN: Return key
  • K_PAUSE: Pause key
  • K_ESCAPE: Escape key
  • K_SPACE: Space key
  • K_EXCLAIM: Exclaim (!) key
  • K_QUOTEDBL: Double quote (") key
  • K_HASH: Hash (#) key
  • K_DOLLAR: Dollar ($) key
  • K_AMPERSAND: Ampersand (&) key
  • K_QUOTE: Quote (') key
  • K_LEFTPAREN: Left parenthesis (() key
  • K_RIGHTPAREN: Right parenthesis ()) key
  • K_ASTERISK: Asterisk (*) key
  • K_PLUS: Plus (+) key
  • K_COMMA: Comma (,) key
  • K_MINUS: Minus (-) key
  • K_PERIOD: Period (.) key
  • K_SLASH: Forward slash (/) key
  • K_0 to K_9: Numeric keys 0 to 9
  • K_COLON: Colon (:) key
  • K_SEMICOLON: Semicolon (;) key
  • K_LESS: Less than (<) key
  • K_EQUALS: Equals (=) key
  • K_GREATER: Greater than (>) key
  • K_QUESTION: Question mark (?) key
  • K_AT: At (@) key
  • K_LEFTBRACKET: Left bracket ([) key
  • K_BACKSLASH: Backslash () key
  • K_RIGHTBRACKET: Right bracket (]) key
  • K_CARET: Caret (^) key
  • K_UNDERSCORE: Underscore (_) key
  • K_BACKQUOTE: Backquote (`) key
  • K_a to K_z: Alphabetic keys a to z
  • K_DELETE: Delete key
  • K_KP0 to K_KP9: Numeric keypad keys 0 to 9
  • K_KP_PERIOD: Keypad period (.) key
  • K_KP_DIVIDE: Keypad divide (/) key
  • K_KP_MULTIPLY: Keypad multiply (*) key
  • K_KP_MINUS: Keypad minus (-) key
  • K_KP_PLUS: Keypad plus (+) key
  • K_KP_ENTER: Keypad enter key
  • K_KP_EQUALS: Keypad equals (=) key
  • K_UP: Up arrow key
  • K_DOWN: Down arrow key
  • K_RIGHT: Right arrow key
  • K_LEFT: Left arrow key
  • K_INSERT: Insert key
  • K_HOME: Home key
  • K_END: End key
  • K_PAGEUP: Page up key
  • K_PAGEDOWN: Page down key
  • K_F1 to K_F15: Function keys F1 to F15
  • K_NUMLOCK: Num Lock key
  • K_CAPSLOCK: Caps Lock key
  • K_SCROLLOCK: Scroll Lock key
  • K_RSHIFT: Right Shift key
  • K_LSHIFT: Left Shift key
  • K_RCTRL: Right Control key
  • K_LCTRL: Left Control key
  • K_RALT: Right Alt key
  • K_LALT: Left Alt key
  • K_RMETA: Right Meta key
  • K_LMETA: Left Meta key
  • K_LSUPER: Left Super key
  • K_RSUPER: Right Super key
  • K_MODE: Mode key
  • K_HELP: Help key
  • K_PRINT: Print key
  • K_SYSREQ: SysReq key
  • K_BREAK: Break key
  • K_MENU: Menu key
  • K_POWER: Power key
  • K_EURO: Euro key
  • K_AC_BACK: AC Back key