Virtual Key Codes Update
-
Virtual-Key Codes Update
The NP++ manual mentions the Virtual Key Number that is used for the
keyattribute inshortcuts.xml.It mentions a “complete list” which can be found on the repo at keys.h, but that file is far from complete. My `shortcuts.xml` file, for instance, mentions key
117, which isF6, and is not defined inkeys.h.Further, the
keys.hfile only lists the hexadecimal values, while `shortcuts.xml` uses the decimal values.To that end, I thought it would be useful to have a proper list for my own reference, and I’m sharing it here.
The table below is a heavily adapted version of the table at https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes, showing the symbolic constant names, hexadecimal values, decimal values, availability, and mouse or keyboard equivalents for the virtual-key codes used by Windows. The codes have been grouped by how useful they may be for making shortcuts.
Please note: the keycode represents the key regardless of any modifier key (e.g.,
Ctrl,altorshift). You specify the modifier keys in theshortcuts.xmlfile. So if the table says that a common key (like the letterA) is a good shortcut key, it means it’s a good key if you combine it with a modifier key.The table has been split into two parts to accommodate the 16384-character post limitation.
Constant Value Decimal Availability Description Best choice: Best default picks for Notepad++ shortcuts. VK_BACK0x08 8 Recommended Backspace key VK_TAB0x09 9 Recommended Tab key VK_RETURN0x0D 13 Recommended Enter key VK_ESCAPE0x1B 27 Recommended Esc key VK_SPACE0x20 32 Recommended Spacebar key VK_PRIOR0x21 33 Recommended Page up key VK_NEXT0x22 34 Recommended Page down key VK_END0x23 35 Recommended End key VK_HOME0x24 36 Recommended Home key VK_LEFT0x25 37 Recommended Left arrow key VK_UP0x26 38 Recommended Up arrow key VK_RIGHT0x27 39 Recommended Right arrow key VK_DOWN0x28 40 Recommended Down arrow key VK_INSERT0x2D 45 Recommended Insert key VK_DELETE0x2E 46 Recommended Delete key 0 0x30 48 Recommended 0 key 1 0x31 49 Recommended 1 key 2 0x32 50 Recommended 2 key 3 0x33 51 Recommended 3 key 4 0x34 52 Recommended 4 key 5 0x35 53 Recommended 5 key 6 0x36 54 Recommended 6 key 7 0x37 55 Recommended 7 key 8 0x38 56 Recommended 8 key 9 0x39 57 Recommended 9 key A 0x41 65 Recommended A key B 0x42 66 Recommended B key C 0x43 67 Recommended C key D 0x44 68 Recommended D key E 0x45 69 Recommended E key F 0x46 70 Recommended F key G 0x47 71 Recommended G key H 0x48 72 Recommended H key I 0x49 73 Recommended I key J 0x4A 74 Recommended J key K 0x4B 75 Recommended K key L 0x4C 76 Recommended L key M 0x4D 77 Recommended M key N 0x4E 78 Recommended N key O 0x4F 79 Recommended O key P 0x50 80 Recommended P key Q 0x51 81 Recommended Q key R 0x52 82 Recommended R key S 0x53 83 Recommended S key T 0x54 84 Recommended T key U 0x55 85 Recommended U key V 0x56 86 Recommended V key W 0x57 87 Recommended W key X 0x58 88 Recommended X key Y 0x59 89 Recommended Y key Z 0x5A 90 Recommended Z key VK_NUMPAD00x60 96 Recommended, if numpad present Numeric keypad 0 key VK_NUMPAD10x61 97 Recommended, if numpad present Numeric keypad 1 key VK_NUMPAD20x62 98 Recommended, if numpad present Numeric keypad 2 key VK_NUMPAD30x63 99 Recommended, if numpad present Numeric keypad 3 key VK_NUMPAD40x64 100 Recommended, if numpad present Numeric keypad 4 key VK_NUMPAD50x65 101 Recommended, if numpad present Numeric keypad 5 key VK_NUMPAD60x66 102 Recommended, if numpad present Numeric keypad 6 key VK_NUMPAD70x67 103 Recommended, if numpad present Numeric keypad 7 key VK_NUMPAD80x68 104 Recommended, if numpad present Numeric keypad 8 key VK_NUMPAD90x69 105 Recommended, if numpad present Numeric keypad 9 key VK_MULTIPLY0x6A 106 Recommended, if numpad present Multiply key VK_ADD0x6B 107 Recommended, if numpad present Add key VK_SEPARATOR0x6C 108 Recommended, if numpad present Separator key VK_SUBTRACT0x6D 109 Recommended, if numpad present Subtract key VK_DECIMAL0x6E 110 Recommended, if numpad present Decimal key VK_DIVIDE0x6F 111 Recommended, if numpad present Divide key VK_F10x70 112 Recommended F1 key VK_F20x71 113 Recommended F2 key VK_F30x72 114 Recommended F3 key VK_F40x73 115 Recommended F4 key VK_F50x74 116 Recommended F5 key VK_F60x75 117 Recommended F6 key VK_F70x76 118 Recommended F7 key VK_F80x77 119 Recommended F8 key VK_F90x78 120 Recommended F9 key VK_F100x79 121 Recommended F10 key VK_F110x7A 122 Recommended F11 key VK_F120x7B 123 Recommended F12 key Usable, but layout-dependent: Real keys, but labeling/position varies by keyboard layout. VK_OEM_10xBA 186 Layout-dependent It can vary by keyboard. For the US ANSI keyboard , the Semiсolon and Colon key VK_OEM_PLUS0xBB 187 Layout-dependent For any country/region, the Equals and Plus key VK_OEM_COMMA0xBC 188 Layout-dependent For any country/region, the Comma and Less Than key VK_OEM_MINUS0xBD 189 Layout-dependent For any country/region, the Dash and Underscore key VK_OEM_PERIOD0xBE 190 Layout-dependent For any country/region, the Period and Greater Than key VK_OEM_20xBF 191 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Forward Slash and Question Mark key VK_OEM_30xC0 192 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Grave Accent and Tilde key VK_OEM_40xDB 219 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Left Brace key VK_OEM_50xDC 220 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Backslash and Pipe key VK_OEM_60xDD 221 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Right Brace key VK_OEM_70xDE 222 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Apostrophe and Double Quotation Mark key VK_OEM_80xDF 223 Layout-dependent It can vary by keyboard. For the Canadian CSA keyboard, the Right Ctrl key VK_OEM_1020xE2 226 Layout-dependent It can vary by keyboard. For the European ISO keyboard, the Backslash and Pipe key Valid, but poor candidate: Windows-defined, but awkward, optional, or likely to conflict. VK_CANCEL0x03 3 Uncommon/awkward Control-break processing VK_CLEAR0x0C 12 Uncommon/awkward Clear key VK_PAUSE0x13 19 Uncommon/awkward Pause key VK_CAPITAL0x14 20 Uncommon/awkward Caps lock key VK_SELECT0x29 41 Uncommon/awkward Select key VK_PRINT0x2A 42 Uncommon/awkward Print key VK_EXECUTE0x2B 43 Uncommon/awkward Execute key VK_SNAPSHOT0x2C 44 Uncommon/awkward Print screen key VK_HELP0x2F 47 Uncommon/awkward Help key VK_LWIN0x5B 91 OS-sensitive Left Windows logo key VK_RWIN0x5C 92 OS-sensitive Right Windows logo key VK_APPS0x5D 93 OS-sensitive Application key VK_SLEEP0x5F 95 Optional hardware Computer Sleep key VK_F130x7C 124 Usually absent F13 key VK_F140x7D 125 Usually absent F14 key VK_F150x7E 126 Usually absent F15 key VK_F160x7F 127 Usually absent F16 key VK_F170x80 128 Usually absent F17 key VK_F180x81 129 Usually absent F18 key VK_F190x82 130 Usually absent F19 key VK_F200x83 131 Usually absent F20 key VK_F210x84 132 Usually absent F21 key VK_F220x85 133 Usually absent F22 key VK_F230x86 134 Usually absent F23 key VK_F240x87 135 Usually absent F24 key VK_NUMLOCK0x90 144 Uncommon/awkward Num lock key VK_SCROLL0x91 145 Uncommon/awkward Scroll lock key VK_BROWSER_BACK0xA6 166 Optional hardware Browser Back key VK_BROWSER_FORWARD0xA7 167 Optional hardware Browser Forward key VK_BROWSER_REFRESH0xA8 168 Optional hardware Browser Refresh key VK_BROWSER_STOP0xA9 169 Optional hardware Browser Stop key VK_BROWSER_SEARCH0xAA 170 Optional hardware Browser Search key VK_BROWSER_FAVORITES0xAB 171 Optional hardware Browser Favorites key VK_BROWSER_HOME0xAC 172 Optional hardware Browser Start and Home key VK_VOLUME_MUTE0xAD 173 Optional hardware Volume Mute key VK_VOLUME_DOWN0xAE 174 Optional hardware Volume Down key VK_VOLUME_UP0xAF 175 Optional hardware Volume Up key VK_MEDIA_NEXT_TRACK0xB0 176 Optional hardware Next Track key VK_MEDIA_PREV_TRACK0xB1 177 Optional hardware Previous Track key VK_MEDIA_STOP0xB2 178 Optional hardware Stop Media key VK_MEDIA_PLAY_PAUSE0xB3 179 Optional hardware Play/Pause Media key VK_LAUNCH_MAIL0xB4 180 Optional hardware Start Mail key VK_LAUNCH_MEDIA_SELECT0xB5 181 Optional hardware Select Media key VK_LAUNCH_APP10xB6 182 Optional hardware Start Application 1 key VK_LAUNCH_APP20xB7 183 Optional hardware Start Application 2 key VK_GAMEPAD_A0xC3 195 Controller-specific Gamepad A button VK_GAMEPAD_B0xC4 196 Controller-specific Gamepad B button VK_GAMEPAD_X0xC5 197 Controller-specific Gamepad X button VK_GAMEPAD_Y0xC6 198 Controller-specific Gamepad Y button VK_GAMEPAD_RIGHT_SHOULDER0xC7 199 Controller-specific Gamepad Right Shoulder button VK_GAMEPAD_LEFT_SHOULDER0xC8 200 Controller-specific Gamepad Left Shoulder button VK_GAMEPAD_LEFT_TRIGGER0xC9 201 Controller-specific Gamepad Left Trigger button VK_GAMEPAD_RIGHT_TRIGGER0xCA 202 Controller-specific Gamepad Right Trigger button VK_GAMEPAD_DPAD_UP0xCB 203 Controller-specific Gamepad D-pad Up button VK_GAMEPAD_DPAD_DOWN0xCC 204 Controller-specific Gamepad D-pad Down button VK_GAMEPAD_DPAD_LEFT0xCD 205 Controller-specific Gamepad D-pad Left button VK_GAMEPAD_DPAD_RIGHT0xCE 206 Controller-specific Gamepad D-pad Right button VK_GAMEPAD_MENU0xCF 207 Controller-specific Gamepad Menu/Start button VK_GAMEPAD_VIEW0xD0 208 Controller-specific Gamepad View/Back button VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON0xD1 209 Controller-specific Gamepad Left Thumbstick button VK_GAMEPAD_RIGHT_THUMBSTICK_BUTTON0xD2 210 Controller-specific Gamepad Right Thumbstick button VK_GAMEPAD_LEFT_THUMBSTICK_UP0xD3 211 Controller-specific Gamepad Left Thumbstick up VK_GAMEPAD_LEFT_THUMBSTICK_DOWN0xD4 212 Controller-specific Gamepad Left Thumbstick down VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT0xD5 213 Controller-specific Gamepad Left Thumbstick right VK_GAMEPAD_LEFT_THUMBSTICK_LEFT0xD6 214 Controller-specific Gamepad Left Thumbstick left VK_GAMEPAD_RIGHT_THUMBSTICK_UP0xD7 215 Controller-specific Gamepad Right Thumbstick up VK_GAMEPAD_RIGHT_THUMBSTICK_DOWN0xD8 216 Controller-specific Gamepad Right Thumbstick down VK_GAMEPAD_RIGHT_THUMBSTICK_RIGHT0xD9 217 Controller-specific Gamepad Right Thumbstick right VK_GAMEPAD_RIGHT_THUMBSTICK_LEFT0xDA 218 Controller-specific Gamepad Right Thumbstick left VK_ATTN0xF6 246 Uncommon/awkward Attn key VK_CRSEL0xF7 247 Uncommon/awkward CrSel key VK_EXSEL0xF8 248 Uncommon/awkward ExSel key VK_EREOF0xF9 249 Uncommon/awkward Erase EOF key VK_PLAY0xFA 250 Uncommon/awkward Play key VK_ZOOM0xFB 251 Uncommon/awkward Zoom key VK_PA10xFD 253 Uncommon/awkward PA1 key VK_OEM_CLEAR0xFE 254 Uncommon/awkward Clear key -
@pbarney said in Virtual Key Codes Update:
It mentions a “complete list” which can be found on the repo at keys.h , but that file is far from complete.
Good point. That phraseology was left over from the pre-2017 wiki-based manual, which was known to be out-of-date and innacurate, but it was a monumental task to update that, and some things weren’t always reworded in the best manner.
The modern User Manual does, however, also point to a few posts here, which in turn lead to our FAQ: FAQ: List of Notepad++ key combinations, available for shortcuts. I should remove the word “complete” from the UM, and point directly to the FAQ. However, you might want to double check your list against the FAQ, to let us know if the FAQ is missing any.
Please note that many in your table, like the VK_GAMEPAD*, are technically “reserved” in the official list, and are dependent on Windows keyboard settings and localization
A more-complete list is found in
namedKeyArray[]in shortcut.cpp – in that, that is the list that modern Notepad++ now uses when generating the list of available keys in Shortcuts (and it uses win32 API calls to ensure that for reserved and oem-specific keycodes, it provides the right name based on your current Windows keyboard settings) – so it’s a complete list of what Notepad++ actually allows via the GUI.
update: https://npp-user-manual.org/docs/config-files/#virtual-key-number has been updated to stop calling
keys.h“complete”; it now links to a section of the codebase inshortcut.cppthat lists all the keycodes available to the Shortcut Mapper GUI, and links to the official MS documentation. Also, the text links to the FAQ rather than the individual posts for finding keycodes. And it explains how to usecalc.exeto convert the hex listed in the source code or the MS docs into decimal for use in thekey="###"attributes inshortcuts.xml.