Keys - JakeTurner616/pygame-lua-bindings GitHub Wiki
get_focused()
Check if the Pygame window is currently focused.
Returns::
Trueif the Pygame window is focused,Falseotherwise.
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. IfNone, 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 isTrue.
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 keyK_TAB: Tab keyK_CLEAR: Clear keyK_RETURN: Return keyK_PAUSE: Pause keyK_ESCAPE: Escape keyK_SPACE: Space keyK_EXCLAIM: Exclaim (!) keyK_QUOTEDBL: Double quote (") keyK_HASH: Hash (#) keyK_DOLLAR: Dollar ($) keyK_AMPERSAND: Ampersand (&) keyK_QUOTE: Quote (') keyK_LEFTPAREN: Left parenthesis (() keyK_RIGHTPAREN: Right parenthesis ()) keyK_ASTERISK: Asterisk (*) keyK_PLUS: Plus (+) keyK_COMMA: Comma (,) keyK_MINUS: Minus (-) keyK_PERIOD: Period (.) keyK_SLASH: Forward slash (/) keyK_0toK_9: Numeric keys 0 to 9K_COLON: Colon (:) keyK_SEMICOLON: Semicolon (;) keyK_LESS: Less than (<) keyK_EQUALS: Equals (=) keyK_GREATER: Greater than (>) keyK_QUESTION: Question mark (?) keyK_AT: At (@) keyK_LEFTBRACKET: Left bracket ([) keyK_BACKSLASH: Backslash () keyK_RIGHTBRACKET: Right bracket (]) keyK_CARET: Caret (^) keyK_UNDERSCORE: Underscore (_) keyK_BACKQUOTE: Backquote (`) keyK_atoK_z: Alphabetic keys a to zK_DELETE: Delete keyK_KP0toK_KP9: Numeric keypad keys 0 to 9K_KP_PERIOD: Keypad period (.) keyK_KP_DIVIDE: Keypad divide (/) keyK_KP_MULTIPLY: Keypad multiply (*) keyK_KP_MINUS: Keypad minus (-) keyK_KP_PLUS: Keypad plus (+) keyK_KP_ENTER: Keypad enter keyK_KP_EQUALS: Keypad equals (=) keyK_UP: Up arrow keyK_DOWN: Down arrow keyK_RIGHT: Right arrow keyK_LEFT: Left arrow keyK_INSERT: Insert keyK_HOME: Home keyK_END: End keyK_PAGEUP: Page up keyK_PAGEDOWN: Page down keyK_F1toK_F15: Function keys F1 to F15K_NUMLOCK: Num Lock keyK_CAPSLOCK: Caps Lock keyK_SCROLLOCK: Scroll Lock keyK_RSHIFT: Right Shift keyK_LSHIFT: Left Shift keyK_RCTRL: Right Control keyK_LCTRL: Left Control keyK_RALT: Right Alt keyK_LALT: Left Alt keyK_RMETA: Right Meta keyK_LMETA: Left Meta keyK_LSUPER: Left Super keyK_RSUPER: Right Super keyK_MODE: Mode keyK_HELP: Help keyK_PRINT: Print keyK_SYSREQ: SysReq keyK_BREAK: Break keyK_MENU: Menu keyK_POWER: Power keyK_EURO: Euro keyK_AC_BACK: AC Back key