Community
    • Login

    Virtual Key Codes Update

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 34 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • pbarneyP
      pbarney
      last edited by

      Virtual-Key Codes Update

      The NP++ manual mentions the Virtual Key Number that is used for the key attribute in shortcuts.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 is F6, and is not defined in keys.h.

      Further, the keys.h file 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, alt or shift). You specify the modifier keys in the shortcuts.xml file. So if the table says that a common key (like the letter A) 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_BACK 0x08 8 Recommended Backspace key
      VK_TAB 0x09 9 Recommended Tab key
      VK_RETURN 0x0D 13 Recommended Enter key
      VK_ESCAPE 0x1B 27 Recommended Esc key
      VK_SPACE 0x20 32 Recommended Spacebar key
      VK_PRIOR 0x21 33 Recommended Page up key
      VK_NEXT 0x22 34 Recommended Page down key
      VK_END 0x23 35 Recommended End key
      VK_HOME 0x24 36 Recommended Home key
      VK_LEFT 0x25 37 Recommended Left arrow key
      VK_UP 0x26 38 Recommended Up arrow key
      VK_RIGHT 0x27 39 Recommended Right arrow key
      VK_DOWN 0x28 40 Recommended Down arrow key
      VK_INSERT 0x2D 45 Recommended Insert key
      VK_DELETE 0x2E 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_NUMPAD0 0x60 96 Recommended, if numpad present Numeric keypad 0 key
      VK_NUMPAD1 0x61 97 Recommended, if numpad present Numeric keypad 1 key
      VK_NUMPAD2 0x62 98 Recommended, if numpad present Numeric keypad 2 key
      VK_NUMPAD3 0x63 99 Recommended, if numpad present Numeric keypad 3 key
      VK_NUMPAD4 0x64 100 Recommended, if numpad present Numeric keypad 4 key
      VK_NUMPAD5 0x65 101 Recommended, if numpad present Numeric keypad 5 key
      VK_NUMPAD6 0x66 102 Recommended, if numpad present Numeric keypad 6 key
      VK_NUMPAD7 0x67 103 Recommended, if numpad present Numeric keypad 7 key
      VK_NUMPAD8 0x68 104 Recommended, if numpad present Numeric keypad 8 key
      VK_NUMPAD9 0x69 105 Recommended, if numpad present Numeric keypad 9 key
      VK_MULTIPLY 0x6A 106 Recommended, if numpad present Multiply key
      VK_ADD 0x6B 107 Recommended, if numpad present Add key
      VK_SEPARATOR 0x6C 108 Recommended, if numpad present Separator key
      VK_SUBTRACT 0x6D 109 Recommended, if numpad present Subtract key
      VK_DECIMAL 0x6E 110 Recommended, if numpad present Decimal key
      VK_DIVIDE 0x6F 111 Recommended, if numpad present Divide key
      VK_F1 0x70 112 Recommended F1 key
      VK_F2 0x71 113 Recommended F2 key
      VK_F3 0x72 114 Recommended F3 key
      VK_F4 0x73 115 Recommended F4 key
      VK_F5 0x74 116 Recommended F5 key
      VK_F6 0x75 117 Recommended F6 key
      VK_F7 0x76 118 Recommended F7 key
      VK_F8 0x77 119 Recommended F8 key
      VK_F9 0x78 120 Recommended F9 key
      VK_F10 0x79 121 Recommended F10 key
      VK_F11 0x7A 122 Recommended F11 key
      VK_F12 0x7B 123 Recommended F12 key
      Usable, but layout-dependent: Real keys, but labeling/position varies by keyboard layout.
      VK_OEM_1 0xBA 186 Layout-dependent It can vary by keyboard. For the US ANSI keyboard , the Semiсolon and Colon key
      VK_OEM_PLUS 0xBB 187 Layout-dependent For any country/region, the Equals and Plus key
      VK_OEM_COMMA 0xBC 188 Layout-dependent For any country/region, the Comma and Less Than key
      VK_OEM_MINUS 0xBD 189 Layout-dependent For any country/region, the Dash and Underscore key
      VK_OEM_PERIOD 0xBE 190 Layout-dependent For any country/region, the Period and Greater Than key
      VK_OEM_2 0xBF 191 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Forward Slash and Question Mark key
      VK_OEM_3 0xC0 192 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Grave Accent and Tilde key
      VK_OEM_4 0xDB 219 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Left Brace key
      VK_OEM_5 0xDC 220 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Backslash and Pipe key
      VK_OEM_6 0xDD 221 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Right Brace key
      VK_OEM_7 0xDE 222 Layout-dependent It can vary by keyboard. For the US ANSI keyboard, the Apostrophe and Double Quotation Mark key
      VK_OEM_8 0xDF 223 Layout-dependent It can vary by keyboard. For the Canadian CSA keyboard, the Right Ctrl key
      VK_OEM_102 0xE2 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_CANCEL 0x03 3 Uncommon/awkward Control-break processing
      VK_CLEAR 0x0C 12 Uncommon/awkward Clear key
      VK_PAUSE 0x13 19 Uncommon/awkward Pause key
      VK_CAPITAL 0x14 20 Uncommon/awkward Caps lock key
      VK_SELECT 0x29 41 Uncommon/awkward Select key
      VK_PRINT 0x2A 42 Uncommon/awkward Print key
      VK_EXECUTE 0x2B 43 Uncommon/awkward Execute key
      VK_SNAPSHOT 0x2C 44 Uncommon/awkward Print screen key
      VK_HELP 0x2F 47 Uncommon/awkward Help key
      VK_LWIN 0x5B 91 OS-sensitive Left Windows logo key
      VK_RWIN 0x5C 92 OS-sensitive Right Windows logo key
      VK_APPS 0x5D 93 OS-sensitive Application key
      VK_SLEEP 0x5F 95 Optional hardware Computer Sleep key
      VK_F13 0x7C 124 Usually absent F13 key
      VK_F14 0x7D 125 Usually absent F14 key
      VK_F15 0x7E 126 Usually absent F15 key
      VK_F16 0x7F 127 Usually absent F16 key
      VK_F17 0x80 128 Usually absent F17 key
      VK_F18 0x81 129 Usually absent F18 key
      VK_F19 0x82 130 Usually absent F19 key
      VK_F20 0x83 131 Usually absent F20 key
      VK_F21 0x84 132 Usually absent F21 key
      VK_F22 0x85 133 Usually absent F22 key
      VK_F23 0x86 134 Usually absent F23 key
      VK_F24 0x87 135 Usually absent F24 key
      VK_NUMLOCK 0x90 144 Uncommon/awkward Num lock key
      VK_SCROLL 0x91 145 Uncommon/awkward Scroll lock key
      VK_BROWSER_BACK 0xA6 166 Optional hardware Browser Back key
      VK_BROWSER_FORWARD 0xA7 167 Optional hardware Browser Forward key
      VK_BROWSER_REFRESH 0xA8 168 Optional hardware Browser Refresh key
      VK_BROWSER_STOP 0xA9 169 Optional hardware Browser Stop key
      VK_BROWSER_SEARCH 0xAA 170 Optional hardware Browser Search key
      VK_BROWSER_FAVORITES 0xAB 171 Optional hardware Browser Favorites key
      VK_BROWSER_HOME 0xAC 172 Optional hardware Browser Start and Home key
      VK_VOLUME_MUTE 0xAD 173 Optional hardware Volume Mute key
      VK_VOLUME_DOWN 0xAE 174 Optional hardware Volume Down key
      VK_VOLUME_UP 0xAF 175 Optional hardware Volume Up key
      VK_MEDIA_NEXT_TRACK 0xB0 176 Optional hardware Next Track key
      VK_MEDIA_PREV_TRACK 0xB1 177 Optional hardware Previous Track key
      VK_MEDIA_STOP 0xB2 178 Optional hardware Stop Media key
      VK_MEDIA_PLAY_PAUSE 0xB3 179 Optional hardware Play/Pause Media key
      VK_LAUNCH_MAIL 0xB4 180 Optional hardware Start Mail key
      VK_LAUNCH_MEDIA_SELECT 0xB5 181 Optional hardware Select Media key
      VK_LAUNCH_APP1 0xB6 182 Optional hardware Start Application 1 key
      VK_LAUNCH_APP2 0xB7 183 Optional hardware Start Application 2 key
      VK_GAMEPAD_A 0xC3 195 Controller-specific Gamepad A button
      VK_GAMEPAD_B 0xC4 196 Controller-specific Gamepad B button
      VK_GAMEPAD_X 0xC5 197 Controller-specific Gamepad X button
      VK_GAMEPAD_Y 0xC6 198 Controller-specific Gamepad Y button
      VK_GAMEPAD_RIGHT_SHOULDER 0xC7 199 Controller-specific Gamepad Right Shoulder button
      VK_GAMEPAD_LEFT_SHOULDER 0xC8 200 Controller-specific Gamepad Left Shoulder button
      VK_GAMEPAD_LEFT_TRIGGER 0xC9 201 Controller-specific Gamepad Left Trigger button
      VK_GAMEPAD_RIGHT_TRIGGER 0xCA 202 Controller-specific Gamepad Right Trigger button
      VK_GAMEPAD_DPAD_UP 0xCB 203 Controller-specific Gamepad D-pad Up button
      VK_GAMEPAD_DPAD_DOWN 0xCC 204 Controller-specific Gamepad D-pad Down button
      VK_GAMEPAD_DPAD_LEFT 0xCD 205 Controller-specific Gamepad D-pad Left button
      VK_GAMEPAD_DPAD_RIGHT 0xCE 206 Controller-specific Gamepad D-pad Right button
      VK_GAMEPAD_MENU 0xCF 207 Controller-specific Gamepad Menu/Start button
      VK_GAMEPAD_VIEW 0xD0 208 Controller-specific Gamepad View/Back button
      VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON 0xD1 209 Controller-specific Gamepad Left Thumbstick button
      VK_GAMEPAD_RIGHT_THUMBSTICK_BUTTON 0xD2 210 Controller-specific Gamepad Right Thumbstick button
      VK_GAMEPAD_LEFT_THUMBSTICK_UP 0xD3 211 Controller-specific Gamepad Left Thumbstick up
      VK_GAMEPAD_LEFT_THUMBSTICK_DOWN 0xD4 212 Controller-specific Gamepad Left Thumbstick down
      VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT 0xD5 213 Controller-specific Gamepad Left Thumbstick right
      VK_GAMEPAD_LEFT_THUMBSTICK_LEFT 0xD6 214 Controller-specific Gamepad Left Thumbstick left
      VK_GAMEPAD_RIGHT_THUMBSTICK_UP 0xD7 215 Controller-specific Gamepad Right Thumbstick up
      VK_GAMEPAD_RIGHT_THUMBSTICK_DOWN 0xD8 216 Controller-specific Gamepad Right Thumbstick down
      VK_GAMEPAD_RIGHT_THUMBSTICK_RIGHT 0xD9 217 Controller-specific Gamepad Right Thumbstick right
      VK_GAMEPAD_RIGHT_THUMBSTICK_LEFT 0xDA 218 Controller-specific Gamepad Right Thumbstick left
      VK_ATTN 0xF6 246 Uncommon/awkward Attn key
      VK_CRSEL 0xF7 247 Uncommon/awkward CrSel key
      VK_EXSEL 0xF8 248 Uncommon/awkward ExSel key
      VK_EREOF 0xF9 249 Uncommon/awkward Erase EOF key
      VK_PLAY 0xFA 250 Uncommon/awkward Play key
      VK_ZOOM 0xFB 251 Uncommon/awkward Zoom key
      VK_PA1 0xFD 253 Uncommon/awkward PA1 key
      VK_OEM_CLEAR 0xFE 254 Uncommon/awkward Clear key
      PeterJonesP 1 Reply Last reply Reply Quote 1
      • PeterJonesP
        PeterJones @pbarney
        last edited by PeterJones

        @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 in shortcut.cpp that 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 use calc.exe to convert the hex listed in the source code or the MS docs into decimal for use in the key="###" attributes in shortcuts.xml.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors