Keyboard

Key Codes
Key wxPython constant
key.BACKSPACE wx.WXK_BACK
key.TAB wx.WXK_TAB
key.ENTER wx.WXK_RETURN
key.ESCAPE wx.WXK_ESCAPE
key.SPACE wx.WXK_SPACE
key.DELETE wx.WXK_DELETE
key.SHIFT wx.WXK_SHIFT
key.ALT wx.WXK_ALT
key.CONTROL wx.WXK_CONTROL
key.CAPSLOCK wx.WXK_CAPITAL
key.END wx.WXK_END
key.HOME wx.WXK_HOME
key.LEFT_ARROW wx.WXK_LEFT
key.UP_ARROW wx.WXK_UP
key.RIGHT_ARROW wx.WXK_RIGHT
key.DOWN_ARROW wx.WXK_DOWN
key.PRINT wx.WXK_PRINT
key.INSERT wx.WXK_INSERT
   
key.DIGITS_0 48
key.DIGITS_1 49
key.DIGITS_2 50
key.DIGITS_3 51
key.DIGITS_4 52
key.DIGITS_5 53
key.DIGITS_6 54
key.DIGITS_7 55
key.DIGITS_8 56
key.DIGITS_9 57
   
key.NUMPAD_0 wx.WXK_NUMPAD0
key.NUMPAD_1 wx.WXK_NUMPAD1
key.NUMPAD_2 wx.WXK_NUMPAD2
key.NUMPAD_3 wx.WXK_NUMPAD3
key.NUMPAD_4 wx.WXK_NUMPAD4
key.NUMPAD_5 wx.WXK_NUMPAD5
key.NUMPAD_6 wx.WXK_NUMPAD6
key.NUMPAD_7 wx.WXK_NUMPAD7
key.NUMPAD_8 wx.WXK_NUMPAD8
key.NUMPAD_9 wx.WXK_NUMPAD9
key.MULTIPLY wx.WXK_MULTIPLY
key.ADD wx.WXK_ADD
key.SEPARATOR wx.WXK_SEPARATOR
key.SUBTRACT wx.WXK_SUBTRACT
key.DECIMAL wx.WXK_DECIMAL
key.DIVIDE wx.WXK_DIVIDE
   
key.F1 wx.WXK_F1
key.F2 wx.WXK_F2
key.F3 wx.WXK_F3
key.F4 wx.WXK_F4
key.F5 wx.WXK_F5
key.F6 wx.WXK_F6
key.F7 wx.WXK_F7
key.F8 wx.WXK_F8
key.F9 wx.WXK_F9
key.F10 wx.WXK_F10
key.F11 wx.WXK_F11
key.F12 wx.WXK_F12
   
key.NUMLOCK wx.WXK_NUMLOCK
   
key.PAGEUP wx.WXK_PAGEUP
key.PAGEDOWN wx.WXK_PAGEDOWN
   
key.NUMPAD_ENTER wx.WXK_NUMPAD_ENTER
key.NUMPAD_HOME wx.WXK_NUMPAD_HOME
key.NUMPAD_LEFT wx.WXK_NUMPAD_LEFT
key.NUMPAD_UP wx.WXK_NUMPAD_UP
key.NUMPAD_RIGHT wx.WXK_NUMPAD_RIGHT
key.NUMPAD_DOWN wx.WXK_NUMPAD_DOWN
key.NUMPAD_PAGEUP wx.WXK_NUMPAD_PAGEUP
key.NUMPAD_PAGEDOWN wx.WXK_NUMPAD_PAGEDOWN
key.NUMPAD_END wx.WXK_NUMPAD_END
key.NUMPAD_BEGIN wx.WXK_NUMPAD_BEGIN
key.NUMPAD_INSERT wx.WXK_NUMPAD_INSERT
key.NUMPAD_DELETE wx.WXK_NUMPAD_DELETE
key.NUMPAD_EQUAL wx.WXK_NUMPAD_EQUAL
key.NUMPAD_MULTIPLY wx.WXK_NUMPAD_MULTIPLY
key.NUMPAD_ADD wx.WXK_NUMPAD_ADD
key.NUMPAD_SEPARATOR wx.WXK_NUMPAD_SEPARATOR
key.NUMPAD_SUBTRACT wx.WXK_NUMPAD_SUBTRACT
key.NUMPAD_DECIMAL wx.WXK_NUMPAD_DECIMAL
key.NUMPAD_DIVIDE wx.WXK_NUMPAD_DIVIDE
   
key.COMMA 44
key.PERIOD 46
key.FORWARD_SLASH 47
key.LEFT_BRACKET 91
key.RIGHT_BRACKET 93
key.BACKWARD_SLASH 92
key.MINUS 45
key.EQUAL 43
key.BACKTICK 126

Keydown

This condition is satisfied when a key in the keyboard is pressed.

# Set circle1's velocity when RIGHT_ARROW key is pressed down.
circle1.bind(KEYDOWN, system.evtHandler, key.RIGHT_ARROW, SETVELOCITY,
             **{'vx': 5, 'vy': 0, 'vr': 0})

Manually created code (equivalent to the automatically generated code shown above):

def setVelocity(event, source):
    source.vx = 5
    source.vy = 0
    source.vr = 0

circle1.bind(KEYDOWN, setVelocity, key.RIGHT_ARROW)

Note

If you keep the key pressed down, keydown event keeps firing.

Keyup

This condition is satisfied when a key in the keyboard is released.

# Set circle1's velocity when RIGHT_ARROW key is released.
circle1.bind(KEYUP, system.evtHandler, key.RIGHT_ARROW, SETVELOCITY,
             **{'vx': 0, 'vy': 0, 'vr': 0})

Manually created code (equivalent to the automatically generated code shown above):

def setVelocity(event, source):
    source.vx = 0
    source.vy = 0
    source.vr = 0

circle1.bind(KEYUP, setVelocity, key.RIGHT_ARROW)

Table Of Contents

Previous topic

Mouse

Next topic

Collisions

This Page