Virtual-Key Code
Jump to navigation
Jump to search
Cheat Engine uses Windows Virtual Key (VK) codes for keyboard input and hotkey scripting.
These constants are defined in defines.lua
and can be used in Lua scripts for hotkey registration, key state checks, and automation.
Contents
Common Virtual Key Codes[edit]
VK Name | Value | Description |
---|---|---|
VK_LBUTTON | 1 | Left mouse button |
VK_RBUTTON | 2 | Right mouse button |
VK_XBUTTON1 | 5 | XButton1 (mouse) |
VK_XBUTTON2 | 6 | XButton2 (mouse) |
VK_CANCEL | 3 | Control-break processing |
VK_MBUTTON | 4 | Middle mouse button |
VK_BACK | 8 | Backspace |
VK_TAB | 9 | Tab |
VK_CLEAR | 12 | Clear |
VK_RETURN | 13 | Enter |
VK_SHIFT | 16 | Shift |
VK_CONTROL | 17 | Ctrl |
VK_MENU | 18 | Alt |
VK_PAUSE | 19 | Pause |
VK_CAPITAL | 20 | Caps Lock |
VK_ESCAPE | 27 | Escape |
VK_SPACE | 32 | Spacebar |
VK_PRIOR | 33 | Page Up |
VK_NEXT | 34 | Page Down |
VK_END | 35 | End |
VK_HOME | 36 | Home |
VK_LEFT | 37 | Left Arrow |
VK_UP | 38 | Up Arrow |
VK_RIGHT | 39 | Right Arrow |
VK_DOWN | 40 | Down Arrow |
VK_SELECT | 41 | Select |
VK_PRINT | 42 | |
VK_EXECUTE | 43 | Execute |
VK_SNAPSHOT | 44 | Print Screen |
VK_INSERT | 45 | Insert |
VK_DELETE | 46 | Delete |
VK_HELP | 47 | Help |
VK_0 - VK_9 | 48-57 | Number keys 0-9 |
VK_A - VK_Z | 65-90 | Letter keys A-Z |
VK_LWIN | 91 | Left Windows key |
VK_RWIN | 92 | Right Windows key |
VK_APPS | 93 | Applications key |
VK_NUMPAD0 - VK_NUMPAD9 | 96-105 | Numpad 0-9 |
VK_MULTIPLY | 106 | Numpad * |
VK_ADD | 107 | Numpad + |
VK_SEPARATOR | 108 | Numpad Separator |
VK_SUBTRACT | 109 | Numpad - |
VK_DECIMAL | 110 | Numpad . |
VK_DIVIDE | 111 | Numpad / |
VK_F1 - VK_F24 | 112-135 | Function keys F1-F24 |
VK_NUMLOCK | 144 | Num Lock |
VK_SCROLL | 145 | Scroll Lock |
VK_LSHIFT | 160 | Left Shift |
VK_RSHIFT | 161 | Right Shift |
VK_LCONTROL | 162 | Left Ctrl |
VK_RCONTROL | 163 | Right Ctrl |
VK_LMENU | 164 | Left Alt |
VK_RMENU | 165 | Right Alt |
German Keyboard Notes[edit]
On German keyboards, some keys do not have VK_ names and must be referenced by their numeric value:
VK Name | Value | Key/Description |
---|---|---|
VK_OEM_PLUS | 187 | + |
VK_OEM_COMMA | 188 | , |
VK_ORM_MINUS | 189 | - |
VK_OEM_PERIOD | 190 | . |
VK_OEM_1 | 186 | ü |
VK_OEM_2 | 191 | # |
VK_OEM_3 | 192 | ö |
VK_OEM_4 | 219 | ß |
VK_OEM_5 | 220 | ^ (left of 1, below ESC) |
VK_OEM_6 | 221 | ´ (between ß and BACKSPACE) |
VK_OEM_7 | 222 | ä |
VK_OEM_102 | 226 | < (between Y and LEFT SHIFT) |
Note: For these keys, use the numeric value in Cheat Engine scripts.
How to Find Other Key Codes[edit]
If you need to find the VK code for a key not listed here, use Nirsoft Keyboard State View to identify the key code.
Usage Example[edit]
-- Register a hotkey for F2 local hk = createHotkey(function() print("F2 pressed!") end, VK_F2) -- Check if the left shift key is pressed if isKeyPressed(VK_LSHIFT) then print("Left Shift is pressed") end