Parameter | Type | Description |
keycode | int | The code of the key whose state should be read. |
Type | Description |
int | The state of the requested key - True for held, False for released. |
Fetches the current state of the key named by keycode - held or released. Keycodes refer to physical keys and not characters, so modifiers are reported the same as others. If the requested keycode is outside of the keymap bounds, None is instead returned.
This list is the subset of "basic" keycodes available for both Windows and X systems.
Name | Description |
KEY_CANCEL | Control-Break |
KEY_BACKSPACE | Backspace |
KEY_CLEAR | Clear Scroll |
KEY_PAUSE | Pause/Break |
KEY_ESCAPE | Escape |
KEY_MENU | Alt/Context Menu |
KEY_TAB | Tab |
KEY_RETURN | Return/Enter |
KEY_CAPSLOCK | Capslock |
KEY_SHIFT_L | Left Shift |
KEY_SHIFT_R | Right Shift |
KEY_CONTROL_L | Left Control |
KEY_CONTROL_R | Right Control |
KEY_ALT_L | Left Alt |
KEY_ALT_R | Right Alt |
KEY_KANALOCK | IME Kana Mode Lock |
KEY_KANASHIFT | IME Kana Mode Shift |
KEY_HANGUL | IME Hangul Mode Lock |
KEY_HANJA | IME Hanja Mode Lock |
KEY_KANJI | IME Kanji Mode Lock |
KEY_SPACE | Space |
KEY_PRIOR | Page Up |
KEY_NEXT | Page Down |
KEY_END | End |
KEY_HOME | Home |
KEY_LEFT | Left Arrow |
KEY_UP | Up Arrow |
KEY_RIGHT | Right Arrow |
KEY_DOWN | Down Arrow |
KEY_SELECT | Select |
KEY_PRINT | |
KEY_EXECUTE | Execute |
KEY_INSERT | Insert |
KEY_DELETE | Delete |
KEY_HELP | Help/F1 |
KEY_0 | 0 |
KEY_1 | 1 |
KEY_2 | 2 |
KEY_3 | 3 |
KEY_4 | 4 |
KEY_5 | 5 |
KEY_6 | 6 |
KEY_7 | 7 |
KEY_8 | 8 |
KEY_9 | 9 |
KEY_A | A |
KEY_B | B |
KEY_C | C |
KEY_D | D |
KEY_E | E |
KEY_F | F |
KEY_G | G |
KEY_H | H |
KEY_I | I |
KEY_J | J |
KEY_K | K |
KEY_L | L |
KEY_M | M |
KEY_N | N |
KEY_O | O |
KEY_P | P |
KEY_Q | Q |
KEY_R | R |
KEY_S | S |
KEY_T | T |
KEY_U | U |
KEY_V | V |
KEY_W | W |
KEY_X | X |
KEY_Y | Y |
KEY_Z | Z |
KEY_META_L | Left Meta/Windows/Command |
KEY_META_R | Right Meta/Windows/Command |
KEY_SUPER_L | Left Super/Windows/Command |
KEY_SUPER_R | Right Super/Windows/Command |
KEY_KP_0 | Keypad 0 |
KEY_KP_1 | Keypad 1 |
KEY_KP_2 | Keypad 2 |
KEY_KP_3 | Keypad 3 |
KEY_KP_4 | Keypad 4 |
KEY_KP_5 | Keypad 5 |
KEY_KP_6 | Keypad 6 |
KEY_KP_7 | Keypad 7 |
KEY_KP_8 | Keypad 8 |
KEY_KP_9 | Keypad 9 |
KEY_KP_MULTIPLY | Keypad Multiply/Asterisk |
KEY_KP_ADD | Keypad Add/Plus |
KEY_KP_SEPARATOR | Keypad Separator/Decimal |
KEY_KP_SUBTRACT | Keypad Subtract/Minus/Dash |
KEY_KP_DECIMAL | Keypad Decimal |
KEY_KP_DIVIDE | Keypad Divide/Slash |
KEY_F1 | F1 |
KEY_F2 | F2 |
KEY_F3 | F3 |
KEY_F4 | F4 |
KEY_F5 | F5 |
KEY_F6 | F6 |
KEY_F7 | F7 |
KEY_F8 | F8 |
KEY_F9 | F9 |
KEY_F10 | F10 |
KEY_F11 | F11 |
KEY_F12 | F12 |
KEY_F13 | F13 |
KEY_F14 | F14 |
KEY_F15 | F15 |
KEY_F16 | F16 |
KEY_F17 | F17 |
KEY_F18 | F18 |
KEY_F19 | F19 |
KEY_F20 | F20 |
KEY_F21 | F21 |
KEY_F22 | F22 |
KEY_F23 | F23 |
KEY_F24 | F24 |
KEY_NUMLOCK | Numlock |
KEY_SCROLLLOCK | Scroll Lock |
KEY_ATTN | Interrupt Attention/PA1/Escape |
KEY_EXSELECT | Extended Select/Extension Mode Shift |
KEY_CURSORSELECT | Cursor Select |
KEY_PLAY | Play |
KEY_ERASEEOF | Erase EOF |
KEY_PA1 | PA1 |
import agan
class game():
def create(self):
return self
#
def update(self):
if(agan.getkey(agan.KEY_W)):
agan.log("The W key is held!")
elif(agan.getkey(agan.KEY_L)):
agan.log("The L key is held!")
else:
agan.log("Neither of my keys are held :(")
#
def close(self):
pass