Raw QMK keycodes (not symbolic)

Getting output from printf debugging for QMK is not worth much if it is not known what the QMK key codes actually are. That is, actual numbers, not the symbolic names in the source code.

Some QMK keycodes (raw numbers)

Most of the information here is copied from the QMK page Keycodes Overview (/docs/keycodes.md). I added the raw QMK keycodes (the third column). The first column is the row number in the table (more or less arbitrary); it is for easier reference and a way to see the number of key codes. Note that the raw QMK keycodes seem to be consecutive, but they are not (there are breaks near #3 and #164 (modifier keys)).

The raw codes were observed on a Keychron V5 (ARM-based) and QMK version approximately May 2023, using printf debugging to dump out the raw QMK keycodes.

Note: Some annotation in the table, for example, “= and +”, assumes a United States keyboard layout. It does not match, for example, European keyboard layouts.

Note: It isn’t the case in general in QMK, but all the QMK keycodes shown here are below 256 and from raw code 4 (KC_A) on, they are thus equal to the USB HID usage IDs for a keyboard.

The most common QMK keycodes

# Symbolic QMK
keycode
Raw code
(decimal)
Aliases Description
1 KC_NO 0 aliases: XXXXXXX Ignore this key (NOOP)
2 KC_TRANSPARENT 1 aliases: KC_TRNS, _______ Use the next lowest non-transparent key
3 KC_A 4 a and A
4 KC_B 5 b and B
5 KC_C 6 c and C
6 KC_D 7 d and D
7 KC_E 8 e and E
8 KC_F 9 f and F
9 KC_G 10 g and G
10 KC_H 11 h and H
11 KC_I 12 i and I
12 KC_J 13 j and J
13 KC_K 14 k and K
14 KC_L 15 l and L
15 KC_M 16 m and M
16 KC_N 17 n and N
17 KC_O 18 o and O
18 KC_P 19 p and P
19 KC_Q 20 q and Q
20 KC_R 21 r and R
21 KC_S 22 s and S
22 KC_T 23 t and T
23 KC_U 24 u and U
24 KC_V 25 v and V
25 KC_W 26 w and W
26 KC_X 27 x and X
27 KC_Y 28 y and Y
28 KC_Z 29 z and Z
29 KC_1 30 1 and !
30 KC_2 31 2 and @
31 KC_3 32 3 and #
32 KC_4 33 4 and $
33 KC_5 34 5 and %
34 KC_6 35 6 and ^
35 KC_7 36 7 and &
36 KC_8 37 8 and *
37 KC_9 38 9 and (
38 KC_0 39 0 and )
39 KC_ENTER 40 aliases: KC_ENT Return (Enter)
40 KC_ESCAPE 41 aliases: KC_ESC Escape
41 KC_BACKSPACE 42 aliases: KC_BSPC Delete (Backspace)
42 KC_TAB 43 Tab
43 KC_SPACE 44 aliases: KC_SPC Spacebar
44 KC_MINUS 45 aliases: KC_MINS – and _
45 KC_EQUAL 46 aliases: KC_EQL ‘ = and +
46 KC_LEFT_BRACKET 47 aliases: KC_LBRC [ and {
47 KC_RIGHT_BRACKET 48 aliases: KC_RBRC ] and }
48 KC_BACKSLASH 49 aliases: KC_BSLS \ and |
49 KC_NONUS_HASH 50 aliases: KC_NUHS Non-US # and ~
50 KC_SEMICOLON 51 aliases: KC_SCLN ; and :
51 KC_QUOTE 52 aliases: KC_QUOT ‘ and ”
52 KC_GRAVE 53 aliases: KC_GRV ` and ~
53 KC_COMMA 54 aliases: KC_COMM , and <
54 KC_DOT 55 . and >
55 KC_SLASH 56 aliases: KC_SLSH / and ?
56 KC_CAPS_LOCK 57 aliases: KC_CAPS Caps Lock
57 KC_F1 58 F1
58 KC_F2 59 F2
59 KC_F3 60 F3
60 KC_F4 61 F4
61 KC_F5 62 F5
62 KC_F6 63 F6
63 KC_F7 64 F7
64 KC_F8 65 F8
65 KC_F9 66 F9
66 KC_F10 67 F10
67 KC_F11 68 F11
68 KC_F12 69 F12
69 KC_PRINT_SCREEN 70 aliases: KC_PSCR Print Screen
70 KC_SCROLL_LOCK 71 aliases: KC_SCRL, KC_BRMD Scroll Lock, Brightness Down (macOS)
71 KC_PAUSE 72 aliases: KC_PAUS, KC_BRK, KC_BRMU Pause, Brightness Up (macOS)
72 KC_INSERT 73 aliases: KC_INS Insert
73 KC_HOME 74 Home
74 KC_PAGE_UP 75 aliases: KC_PGUP Page Up
75 KC_DELETE 76 aliases: KC_DEL Forward Delete
76 KC_END 77 End
77 KC_PAGE_DOWN 78 aliases: KC_PGDN Page Down
78 KC_RIGHT 79 aliases: KC_RGHT Right Arrow
79 KC_LEFT 80 Left Arrow
80 KC_DOWN 81 Down Arrow
81 KC_UP 82 Up Arrow
82 KC_NUM_LOCK 83 aliases: KC_NUM Keypad Num Lock and Clear
83 KC_KP_SLASH 84 aliases: KC_PSLS Keypad /
84 KC_KP_ASTERISK 85 aliases: KC_PAST Keypad *
85 KC_KP_MINUS 86 aliases: KC_PMNS Keypad –
86 KC_KP_PLUS 87 aliases: KC_PPLS Keypad +
87 KC_KP_ENTER 88 aliases: KC_PENT Keypad Enter
88 KC_KP_1 89 aliases: KC_P1 Keypad 1 and End
89 KC_KP_2 90 aliases: KC_P2 Keypad 2 and Down Arrow
90 KC_KP_3 91 aliases: KC_P3 Keypad 3 and Page Down
91 KC_KP_4 92 aliases: KC_P4 Keypad 4 and Left Arrow
92 KC_KP_5 93 aliases: KC_P5 Keypad 5
93 KC_KP_6 94 aliases: KC_P6 Keypad 6 and Right Arrow
94 KC_KP_7 95 aliases: KC_P7 Keypad 7 and Home
95 KC_KP_8 96 aliases: KC_P8 Keypad 8 and Up Arrow
96 KC_KP_9 97 aliases: KC_P9 Keypad 9 and Page Up
97 KC_KP_0 98 aliases: KC_P0 Keypad 0 and Insert
98 KC_KP_DOT 99 aliases: KC_PDOT Keypad . and Delete
99 KC_NONUS_BACKSLASH 100 aliases: KC_NUBS Non-US \ and |
100 KC_APPLICATION 101 aliases: KC_APP Application (Windows Context Menu Key)
101 KC_KB_POWER 102 System Power
102 KC_KP_EQUAL 103 aliases: KC_PEQL Keypad =
103 KC_F13 104 F13
104 KC_F14 105 F14
105 KC_F15 106 F15
106 KC_F16 107 F16
107 KC_F17 108 F17
108 KC_F18 109 F18
109 KC_F19 110 F19
110 KC_F20 111 F20
111 KC_F21 112 F21
112 KC_F22 113 F22
113 KC_F23 114 F23
114 KC_F24 115 F24
115 KC_EXECUTE 116 aliases: KC_EXEC Execute
116 KC_HELP 117 Help
117 KC_MENU 118 Menu
118 KC_SELECT 119 aliases: KC_SLCT Select
119 KC_STOP 120 Stop
120 KC_AGAIN 121 aliases: KC_AGIN Again
121 KC_UNDO 122 Undo
122 KC_CUT 123 Cut
123 KC_COPY 124 Copy
124 KC_PASTE 125 aliases: KC_PSTE Paste
125 KC_FIND 126 Find
126 KC_KB_MUTE 127 Mute
127 KC_KB_VOLUME_UP 128 Volume Up
128 KC_KB_VOLUME_DOWN 129 Volume Down
129 KC_LOCKING_CAPS_LOCK 130 aliases: KC_LCAP Locking Caps Lock
130 KC_LOCKING_NUM_LOCK 131 aliases: KC_LNUM Locking Num Lock
131 KC_LOCKING_SCROLL_LOCK 132 aliases: KC_LSCR Locking Scroll Lock
132 KC_KP_COMMA 133 aliases: KC_PCMM Keypad ,
133 KC_KP_EQUAL_AS400 134 Keypad = on AS/400 keyboards
134 KC_INTERNATIONAL_1 135 aliases: KC_INT1 International 1
135 KC_INTERNATIONAL_2 136 aliases: KC_INT2 International 2
136 KC_INTERNATIONAL_3 137 aliases: KC_INT3 International 3
137 KC_INTERNATIONAL_4 138 aliases: KC_INT4 International 4
138 KC_INTERNATIONAL_5 139 aliases: KC_INT5 International 5
139 KC_INTERNATIONAL_6 140 aliases: KC_INT6 International 6
140 KC_INTERNATIONAL_7 141 aliases: KC_INT7 International 7
141 KC_INTERNATIONAL_8 142 aliases: KC_INT8 International 8
142 KC_INTERNATIONAL_9 143 aliases: KC_INT9 International 9
143 KC_LANGUAGE_1 144 aliases: KC_LNG1 Language 1
144 KC_LANGUAGE_2 145 aliases: KC_LNG2 Language 2
145 KC_LANGUAGE_3 146 aliases: KC_LNG3 Language 3
146 KC_LANGUAGE_4 147 aliases: KC_LNG4 Language 4
147 KC_LANGUAGE_5 148 aliases: KC_LNG5 Language 5
148 KC_LANGUAGE_6 149 aliases: KC_LNG6 Language 6
149 KC_LANGUAGE_7 150 aliases: KC_LNG7 Language 7
150 KC_LANGUAGE_8 151 aliases: KC_LNG8 Language 8
151 KC_LANGUAGE_9 152 aliases: KC_LNG9 Language 9
152 KC_ALTERNATE_ERASE 153 aliases: KC_ERAS Alternate Erase
153 KC_SYSTEM_REQUEST 154 aliases: KC_SYRQ SysReq/Attention
154 KC_CANCEL 155 aliases: KC_CNCL Cancel
155 KC_CLEAR 156 aliases: KC_CLR Clear
156 KC_PRIOR 157 aliases: KC_PRIR Prior
157 KC_RETURN 158 aliases: KC_RETN Return
158 KC_SEPARATOR 159 aliases: KC_SEPR Separator
159 KC_OUT 160 Out
160 KC_OPER 161 Oper
161 KC_CLEAR_AGAIN 162 aliases: KC_CLAG Clear/Again
162 KC_CRSEL 163 aliases: KC_CRSL CrSel/Props
163 KC_EXSEL 164 aliases: KC_EXSL ExSel
164 KC_LEFT_CTRL 224 aliases: KC_LCTL Left Control
165 KC_LEFT_SHIFT 225 aliases: KC_LSFT Left Shift
166 KC_LEFT_ALT 226 aliases: KC_LALT, KC_LOPT Left Alt (Option)
167 KC_LEFT_GUI 227 aliases: KC_LGUI, KC_LCMD, KC_LWIN Left GUI (Windows/Command/Meta key)
168 KC_RIGHT_CTRL 228 aliases: KC_RCTL Right Control
169 KC_RIGHT_SHIFT 229 aliases: KC_RSFT Right Shift
170 KC_RIGHT_ALT 230 aliases: KC_RALT, KC_ROPT, KC_ALGR Right Alt (Option/AltGr)
171 KC_RIGHT_GUI 231 aliases: KC_RGUI, KC_RCMD, KC_RWIN Right GUI (Windows/Command/Meta key)
172 KC_SYSTEM_POWER 165 aliases: KC_PWR System Power Down
173 KC_SYSTEM_SLEEP 166 aliases: KC_SLEP System Sleep
174 KC_SYSTEM_WAKE 167 aliases: KC_WAKE System Wake
175 KC_AUDIO_MUTE 168 aliases: KC_MUTE Mute
176 KC_AUDIO_VOL_UP 169 aliases: KC_VOLU Volume Up
177 KC_AUDIO_VOL_DOWN 170 aliases: KC_VOLD Volume Down
178 KC_MEDIA_NEXT_TRACK 171 aliases: KC_MNXT Next Track
179 KC_MEDIA_PREV_TRACK 172 aliases: KC_MPRV Previous Track
180 KC_MEDIA_STOP 173 aliases: KC_MSTP Stop Track
181 KC_MEDIA_PLAY_PAUSE 174 aliases: KC_MPLY Play/Pause Track
182 KC_MEDIA_SELECT 175 aliases: KC_MSEL Launch Media Player
183 KC_MEDIA_EJECT 176 aliases: KC_EJCT Eject
184 KC_MAIL 177 Launch Mail
185 KC_CALCULATOR 178 aliases: KC_CALC Launch Calculator
186 KC_MY_COMPUTER 179 aliases: KC_MYCM Launch My Computer
187 KC_WWW_SEARCH 180 aliases: KC_WSCH Browser Search
188 KC_WWW_HOME 181 aliases: KC_WHOM Browser Home
189 KC_WWW_BACK 182 aliases: KC_WBAK Browser Back
190 KC_WWW_FORWARD 183 aliases: KC_WFWD Browser Forward
191 KC_WWW_STOP 184 aliases: KC_WSTP Browser Stop
192 KC_WWW_REFRESH 185 aliases: KC_WREF Browser Refresh
193 KC_WWW_FAVORITES 186 aliases: KC_WFAV Browser Favorites
194 KC_MEDIA_FAST_FORWARD 187 aliases: KC_MFFD Next Track
195 KC_MEDIA_REWIND 188 aliases: KC_MRWD Previous Track
196 KC_BRIGHTNESS_UP 189 aliases: KC_BRIU Brightness Up
197 KC_BRIGHTNESS_DOWN 190 aliases: KC_BRID Brightness Down
198 KC_CONTROL_PANEL 191 aliases: KC_CPNL Open Control Panel
199 KC_ASSISTANT 192 aliases: KC_ASST Launch Context-Aware Assistant
200 KC_MISSION_CONTROL 193 aliases: KC_MCTL Open Mission Control
201 KC_LAUNCHPAD 194 aliases: KC_LPAD Open Launchpad

Mouse QMK keycodes

# Symbolic QMK
keycode
Raw code
(decimal)
Aliases Description
1 KC_MS_UP 205 aliases: KC_MS_U Mouse Cursor Up
2 KC_MS_DOWN 206 aliases: KC_MS_D Mouse Cursor Down
3 KC_MS_LEFT 207 aliases: KC_MS_L Mouse Cursor Left
4 KC_MS_RIGHT 208 aliases: KC_MS_R Mouse Cursor Right
5 KC_MS_BTN1 209 aliases: KC_BTN1 Mouse Button 1. AKA Left click
6 KC_MS_BTN2 210 aliases: KC_BTN2 Mouse Button 2. AKA Right click
7 KC_MS_BTN3 211 aliases: KC_BTN3 Mouse Button 3
8 KC_MS_BTN4 212 aliases: KC_BTN4 Mouse Button 4
9 KC_MS_BTN5 213 aliases: KC_BTN5 Mouse Button 5
10 KC_MS_WH_UP 217 aliases: KC_WH_U Mouse Wheel Up
11 KC_MS_WH_DOWN 218 aliases: KC_WH_D Mouse Wheel Down
12 KC_MS_WH_LEFT 219 aliases: KC_WH_L Mouse Wheel Left
13 KC_MS_WH_RIGHT 220 aliases: KC_WH_R Mouse Wheel Right
14 KC_MS_ACCEL0 221 aliases: KC_ACL0 Set mouse acceleration to 0
15 KC_MS_ACCEL1 222 aliases: KC_ACL1 Set mouse acceleration to 1
16 KC_MS_ACCEL2 223 aliases: KC_ACL2 Set mouse acceleration to 2

The process of getting the numbers

I used these steps:

From the official page of QMK keycodes, I copy pasted the main QMK key codes directly from the web page, from the first table, “Basic Keycodes”. It was 201 rows. The columns were tab-separated.

Pasted it into a spreadsheet. This was for later inserting the result, the raw keycodes and for highlighting particular key codes of interest found during debugging in colour. It could be used to export a tab-separated list for some automatic processing.

Copy-pasted the symbolic column (identifier in C code) into a text document and let a small Perl one-liner generate code for insertion in the QMK code.

This was wrapped in XXX and to be dumped out using a helper function:

XXXX

The code was compiled, the QMK keyboard flashed and the dump activated by a particular macro key (note that it could be anywhere, even in init_XXuser(); the point is to output it only once)

The output was captured to a text file and the list of 201 number were pasted in the spreadsheet.

For manual evaluation of the printf debugging, this was sufficient. The actual key codes present were highlighted in the spreadsheet (to easier navigate the long list of keycodes):

Note that keycodes on that official QMK page are mostly ordered by the raw number value, not entirely. Keycodes 3 and 4 are missing and the 10 key codes for modifier keys are inserted out of order after keycode XXX.

Leave a Reply

Your email address will not be published. Required fields are marked *

*