Key Module
The key module is essentially just a table that holds key/value pairs that match virtual key names to virtual key codes. That is, key.VK_ENTER, a value of 13, represents the Enter key on your keyboard. These values are used in keyboard and mouse input. #Virtual Keys

The table below contains a list of all available virtual key codes. While most keys are fairly standardized, a certain few may be different for your specific keyboard layout. Please refer to documentation on your keyboard locale for further details.

Some virtual keys have both a vague and specific copy. For example, key.VK_CONTROL does not refer to either the left or right control keys. Certain applications might expect the specific (left or right) virtual key while others might expect the vague virtual key. Don't be afraid to experiment and see which works best for you.

VK nameValue (in decimal)Note
key.VK_LMOUSE1Left mouse button
key.VK_RMOUSE2Right mouse button
key.VK_CANCEL3The "Control-break" key-code; generally input by CTRL+C
key.VK_MMOUSE4Middle mouse button
key.VK_XMOUSE15"Extra" mouse button 1
key.VK_XMOUSE26"Extra" mouse button 2
key.VK_BACKSPACE8
key.VK_TAB9
key.VK_RETURN13An alias to key.VK_ENTER
key.VK_ENTER13
key.VK_SHIFT16Use key.VK_LSHIFT or key.VK_RSHIFT to further specify
key.VK_CONTROL17Use key.VK_LCONTROL or key.VK_RCONTROL to further specify
key.VK_ALT18Use key.VK_LALT or key.VK_RALT to further specify
key.VK_MENU18An alias to key.VK_ALT
key.VK_PAUSE19
key.VK_CAPITAL20An alias to key.VK_CAPSLOCK
key.VK_CAPSLOCK20
key.VK_ESCAPE27
key.VK_SPACE32
key.VK_PRIOR33An alias to key.VK_PAGEUP
key.VK_PAGEUP33
key.VK_NEXT34An alias to key.VK_PAGEDOWN
key.VK_PAGEDOWN34
key.VK_END35
key.VK_HOME36
key.VK_LEFT37
key.VK_UP38
key.VK_RIGHT39
key.VK_DOWN40
key.VK_PRINT42Deprecated (probably doesn't exist on your keyboard anymore)
key.VK_PRINTSCREEN44
key.VK_SNAPSHOT44An alias to key.VK_PRINTSCREEN
key.VK_INSERT45
key.VK_DELETE46
key.VK_HELP47
key.VK_048From the number row; not the number pad
key.VK_149From the number row; not the number pad
key.VK_250From the number row; not the number pad
key.VK_351From the number row; not the number pad
key.VK_452From the number row; not the number pad
key.VK_553From the number row; not the number pad
key.VK_654From the number row; not the number pad
key.VK_755From the number row; not the number pad
key.VK_856From the number row; not the number pad
key.VK_957From the number row; not the number pad
key.VK_A65
key.VK_B66
key.VK_C67
key.VK_D68
key.VK_E69
key.VK_F70
key.VK_G71
key.VK_H72
key.VK_I73
key.VK_J74
key.VK_K75
key.VK_L76
key.VK_M77
key.VK_N78
key.VK_O79
key.VK_P80
key.VK_Q81
key.VK_R82
key.VK_S83
key.VK_T84
key.VK_U85
key.VK_V86
key.VK_W87
key.VK_X88
key.VK_Y89
key.VK_Z90
key.VK_LWINDOWS91The left "Windows" key
key.VK_LWIN91An alias to key.VK_LWINDOWS
key.VK_RWINDOWS92The right "Windows" key
key.VK_RWIN92An alias to key.VK_RWINDOWS
key.VK_APPS93The "Apps" button, generally next to your right Control key
key.VK_SLEEP95
key.VK_NUMPAD096
key.VK_NUMPAD197
key.VK_NUMPAD298
key.VK_NUMPAD399
key.VK_NUMPAD4100
key.VK_NUMPAD5101
key.VK_NUMPAD6102
key.VK_NUMPAD7103
key.VK_NUMPAD8104
key.VK_NUMPAD9105
key.VK_MULTIPLY106The * key in the number pad
key.VK_ADD107The + key in the number pad
key.VK_SUBTRACT109The - key in the number pad
key.VK_DECIMAL110The . key in the number pad
key.VK_DIVIDE111The / key in the number pad
key.VK_F1112
key.VK_F2113
key.VK_F3114
key.VK_F4115
key.VK_F5116
key.VK_F6117
key.VK_F7118
key.VK_F8119
key.VK_F9120
key.VK_F10121
key.VK_F11122
key.VK_F12123
key.VK_NUMLOCK144
key.VK_SCROLL145
key.VK_LSHIFT160Left shift
key.VK_RSHIFT161Right shift
key.VK_LCONTROL162Left control
key.VK_RCONTROL163Right control
key.VK_LMENU164An alias to key.VK_LALT
key.VK_LALT164Left alt
key.VK_RALT165Right alt
key.VK_RMENU165An alias to key.VK_RALT
key.VK_PLUS187The + key in the number row
key.VK_COMMA188
key.VK_PERIOD190
key.VK_MOUSEMOVE512A virtual key code sent as an event when the mouse is moved
key.VK_MOUSEWHEEL513A virtual key code sent as an event when the mouse wheel is moved

Page last updated at 2018-09-25 20:47:49


Copyright 2018