Key
Keyboard key constants.
Overview
Key is an IntEnum containing constants for all keyboard keys. These values are passed to keyboard input handlers and can be used with the Keyboard singleton to check key states. For backwards compatibility, Key values compare equal to legacy string names.
Quick Reference
import mcrfpy
scene = mcrfpy.Scene("key_demo")
def handle_key(key, state):
if state == mcrfpy.InputState.PRESSED:
if key == mcrfpy.Key.ESCAPE:
print("Escape pressed")
elif key == mcrfpy.Key.SPACE:
print("Space pressed")
elif key == mcrfpy.Key.W:
print("W pressed")
scene.on_key = handle_key
scene.children.append(mcrfpy.Caption(text="Press a key", pos=(10, 10)))
mcrfpy.current_scene = scene
Values
Letters
Numbers (Top Row)
Numpad
| Value |
NUMPAD_0 - NUMPAD_9 |
ADD, SUBTRACT, MULTIPLY, DIVIDE |
Function Keys
Modifiers
| Value |
Description |
LEFT_SHIFT |
Left shift key |
RIGHT_SHIFT |
Right shift key |
LEFT_CONTROL |
Left control key |
RIGHT_CONTROL |
Right control key |
LEFT_ALT |
Left alt key |
RIGHT_ALT |
Right alt key |
LEFT_SYSTEM |
Left system key (Win/Cmd) |
RIGHT_SYSTEM |
Right system key |
Navigation
| Value |
Description |
LEFT |
Left arrow |
RIGHT |
Right arrow |
UP |
Up arrow |
DOWN |
Down arrow |
HOME |
Home key |
END |
End key |
PAGE_UP |
Page up |
PAGE_DOWN |
Page down |
Editing
| Value |
Description |
ENTER |
Enter/Return key |
BACKSPACE |
Backspace key |
DELETE |
Delete key |
INSERT |
Insert key |
TAB |
Tab key |
SPACE |
Spacebar |
ESCAPE |
Escape key |
Symbols
| Value |
Description |
COMMA |
, |
PERIOD |
. |
SLASH |
/ |
BACKSLASH |
\ |
SEMICOLON |
; |
APOSTROPHE |
' |
LEFT_BRACKET |
[ |
RIGHT_BRACKET |
] |
HYPHEN |
- |
EQUAL |
= |
GRAVE |
` |
Other
| Value |
Description |
MENU |
Menu key |
PAUSE |
Pause key |
UNKNOWN |
Unknown/unrecognized key |