aboutsummaryrefslogtreecommitdiff
path: root/docs/quantum_keycodes.md
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2017-06-28 23:52:08 -0700
committerskullY <skullydazed@gmail.com>2017-06-28 23:52:08 -0700
commit910d32c07e5d130bbe59abe11be5459b2381f011 (patch)
treec0dac744d5959471c1ef076f4675cdca3e94b031 /docs/quantum_keycodes.md
parentd5244c6cf4939301b18ecf07650df6a6f9800e07 (diff)
downloadqmk_firmware-910d32c07e5d130bbe59abe11be5459b2381f011.tar.gz
qmk_firmware-910d32c07e5d130bbe59abe11be5459b2381f011.zip
Flesh out the quantum_keycodes documentation
Diffstat (limited to 'docs/quantum_keycodes.md')
-rw-r--r--docs/quantum_keycodes.md357
1 files changed, 216 insertions, 141 deletions
diff --git a/docs/quantum_keycodes.md b/docs/quantum_keycodes.md
index 81eb64701..e9edad03e 100644
--- a/docs/quantum_keycodes.md
+++ b/docs/quantum_keycodes.md
@@ -1,42 +1,50 @@
1# Quantum Keycodes 1# Quantum Keycodes
2 2
3Something important to realise with keycodes is that they are all numbers between `0x0` and `0xFFFF` - even though they may look like functions, words, or phrases, they are all shortcuts to some number. This allows us to define all of what they do in different places, and store keymaps in a relatively small place (arrays). If you try to "call" a keycode by placing it somewhere besides a keymap, it may compile, but it won't do anything useful. 3All keycodes within quantum are numbers between `0x0000` and `0xFFFF`. Within your `keymap.c` it may look like you have functions and other special cases, but ultimately the C preprocessor will translate those into a single 4 byte integer. QMK has reserved `0x0000` through `0x00FF` for standard keycodes. These are keycodes such as `KC_A`, `KC_1`, and `KC_LCTL`, which are basic keys defined in the USB HID specification.
4 4
5All keycodes on this page have a value above `0xFF` (values less are considered the [basic keycodes](basic_keycodes.md)) and won't work with any of the mod/layer-tap keys listed at the bottom. 5On this page we have documented keycodes between `0x00FF` and `0xFFFF` which are used to implement advanced quantum features. If you define your own custom keycodes they will be put into this range as well. Keycodes above `0x00FF` may not be used with any of the mod/layer-tap keys listed
6 6
7* `SAFE_RANGE` is always the last keycode in the quantum list, and where custom lists can begin 7# Quantum keycodes
8* `RESET` puts the keyboard into DFU mode for flashing 8
9* `DEBUG` toggles debug mode 9|Name|Description|
10* Shortcuts for bootmagic options (work when bootmagic is off) 10|----|-----------|
11 * `MAGIC_SWAP_CONTROL_CAPSLOCK` 11|`RESET`|Put the keyboard into DFU mode for flashing|
12 * `MAGIC_CAPSLOCK_TO_CONTROL` 12|`DEBUG`|Toggles debug mode|
13 * `MAGIC_SWAP_LALT_LGUI` 13|`KC_GESC`/`GRAVE_ESC`|Acts as escape when pressed normally but when pressed with Shift or GUI will send a `~`|
14 * `MAGIC_SWAP_RALT_RGUI` 14|`KC_LSPO`|Left shift when held, open paranthesis when tapped|
15 * `MAGIC_NO_GUI` 15|`KC_RSPC`|Right shift when held, close paranthesis when tapped|
16 * `MAGIC_SWAP_GRAVE_ESC` 16|`KC_LEAD`|The [leader key](leader_key.md)|
17 * `MAGIC_SWAP_BACKSLASH_BACKSPACE` 17|`FUNC(n)`/`F(n)`|Call `fn_action(n)`|
18 * `MAGIC_HOST_NKRO` 18|`M(n)`|to call macro n|
19 * `MAGIC_SWAP_ALT_GUI`/`AG_SWAP` 19|`MACROTAP(n)`|to macro-tap n idk FIXME|
20 * `MAGIC_UNSWAP_CONTROL_CAPSLOCK` 20
21 * `MAGIC_UNCAPSLOCK_TO_CONTROL` 21# Bootmagic Keycodes
22 * `MAGIC_UNSWAP_LALT_LGUI` 22
23 * `MAGIC_UNSWAP_RALT_RGUI` 23Shortcuts for bootmagic options (these work even when bootmagic is off.)
24 * `MAGIC_UNNO_GUI` 24
25 * `MAGIC_UNSWAP_GRAVE_ESC` 25|Name|Description|
26 * `MAGIC_UNSWAP_BACKSLASH_BACKSPACE` 26|----|-----------|
27 * `MAGIC_UNHOST_NKRO` 27|`MAGIC_SWAP_CONTROL_CAPSLOCK`|Swap Capslock and Left Control|
28 * `MAGIC_UNSWAP_ALT_GUI`/`AG_NORM` 28|`MAGIC_CAPSLOCK_TO_CONTROL`|Treat Capslock like a Control Key|
29 * `MAGIC_TOGGLE_NKRO` 29|`MAGIC_SWAP_LALT_LGUI`|Swap the left Alt and GUI keys|
30* `KC_GESC`/`GRAVE_ESC` acts as escape when pressed normally but when pressed with a mod will send a `~` 30|`MAGIC_SWAP_RALT_RGUI`|Swap the right Alt and GUI keys|
31* `KC_LSPO` left shift when held, open paranthesis when tapped 31|`MAGIC_NO_GUI`|Disable the GUI key|
32* `KC_RSPC` right shift when held, close paranthesis when tapped 32|`MAGIC_SWAP_GRAVE_ESC`|Swap the Grave and Esc key.|
33* `KC_LEAD` the leader key 33|`MAGIC_SWAP_BACKSLASH_BACKSPACE`|Swap backslack and backspace|
34 34|`MAGIC_HOST_NKRO`|Force NKRO on|
35* `FUNC(n)`/`F(n)` to call `fn_action` n 35|`MAGIC_SWAP_ALT_GUI`/`AG_SWAP`|Swap Alt and Gui on both sides|
36* `M(n)` to call macro n 36|`MAGIC_UNSWAP_CONTROL_CAPSLOCK`|Disable the Control/Capslock swap|
37* `MACROTAP(n)` to macro-tap n idk FIXME 37|`MAGIC_UNCAPSLOCK_TO_CONTROL`|Disable treating Capslock like Control |
38 38|`MAGIC_UNSWAP_LALT_LGUI`|Disable Left Alt and GUI switching|
39## Audio 39|`MAGIC_UNSWAP_RALT_RGUI`|Disable Right Alt and GUI switching|
40|`MAGIC_UNNO_GUI`|Enable the GUI key |
41|`MAGIC_UNSWAP_GRAVE_ESC`|Disable the Grave/Esc swap |
42|`MAGIC_UNSWAP_BACKSLASH_BACKSPACE`|Disable the backslash/backspace swap|
43|`MAGIC_UNHOST_NKRO`|Force NKRO off|
44|`MAGIC_UNSWAP_ALT_GUI`/`AG_NORM`|Disable the Alt/GUI switching|
45|`MAGIC_TOGGLE_NKRO`|Turn NKRO on or off|
46
47# Audio
40 48
41```c 49```c
42#ifdef AUDIO_ENABLE 50#ifdef AUDIO_ENABLE
@@ -126,7 +134,7 @@ MI_TRNSU, // transpose up
126 134
127MI_VEL_x 1-10 135MI_VEL_x 1-10
128MIDI_VELOCITY_MIN = MI_VEL_1, 136MIDI_VELOCITY_MIN = MI_VEL_1,
129MIDI_VELOCITY_MAX = MI_VEL_10, 137MIDI_VELOCITY_MAX = MI_VEL_9,
130MI_VELD, // velocity down 138MI_VELD, // velocity down
131MI_VELU, // velocity up 139MI_VELU, // velocity up
132 140
@@ -149,126 +157,193 @@ MI_MODSD, // decrease modulation speed
149MI_MODSU, // increase modulation speed 157MI_MODSU, // increase modulation speed
150#endif // MIDI_ADVANCED 158#endif // MIDI_ADVANCED
151 159
152## Backlight 160# Backlight
153 161
154* `BL_x` where x = 0-15 162These keycodes control the backlight. Most keyboards use this for single color in-switch lighting.
155* `BL_ON = BL_9`
156* `BL_OFF = BL_0`
157* `BL_DEC`
158* `BL_INC`
159* `BL_TOGG`
160* `BL_STEP`
161 163
162## RGB WS2818 LEDs 164|Name|Description|
165|----|-----------|
166|`BL_x`|Set a specific backlight level between 0-9|
167|`BL_ON`|An alias for `BL_9`|
168|`BL_OFF`|An alias for `BL_0`|
169|`BL_DEC`|Turn the backlight level down by 1|
170|`BL_INC`|Turn the backlight level up by 1|
171|`BL_TOGG`|Toggle the backlight on or off|
172|`BL_STEP`|Step through backlight levels, wrapping around to 0 when you reach the top.|
163 173
164* `RGB_TOG` toggle on/off 174# RGBLIGHT WS2818 LEDs
165* `RGB_MOD` cycle between modes 175
166* `RGB_HUI` hue increase 176This controls the `RGBLIGHT` functionality. Most keyboards use WS2812 (and compatible) LEDs for underlight or case lighting.
167* `RGB_HUD` hue decrease 177
168* `RGB_SAI` saturation increase 178|Name|Description|
169* `RGB_SAD` saturation decrease 179|----|-----------|
170* `RGB_VAI` value increase 180|`RGB_TOG`|toggle on/off|
171* `RGB_VAD` value decrease 181|`RGB_MOD`|cycle through modes|
182|`RGB_HUI`|hue increase|
183|`RGB_HUD`|hue decrease|
184|`RGB_SAI`|saturation increase|
185|`RGB_SAD`|saturation decrease|
186|`RGB_VAI`|value increase|
187|`RGB_VAD`|value decrease|
172 188
173## Thermal Printer (experimental) 189## Thermal Printer (experimental)
174 190
175* `PRINT_ON` 191|Name|Description|
176* `PRINT_OFF` 192|----|-----------|
193|`PRINT_ON`|Start printing everything the user types|
194|`PRINT_OFF`|Stop printing everything the user types|
177 195
178## Keyboard output selection 196## Keyboard output selection
179 197
180* `OUT_AUTO` auto mode 198This is used when multiple keyboard outputs can be selected. Currently this only allows for switching between USB and Bluetooth on keyboards that support both.
181* `OUT_USB` usb only 199
182* `OUT_BT` bluetooth (when `BLUETOOTH_ENABLE`) 200|Name|Description|
201|----|-----------|
202|`OUT_AUTO`|auto mode|
203|`OUT_USB`|usb only|
204|`OUT_BT`|bluetooth (when `BLUETOOTH_ENABLE`)|
205
206# Modifiers
183 207
184## Modifiers 208These are special keycodes that simulate pressing several modifiers at once.
185 209
186* `KC_HYPR` LCTL + LSFT + LALT + LGUI - `MOD_HYPR` is the bit version 210|Name|Description|
187* `KC_MEH` LCTL + LSFT + LALT - `MOD_MEH` is the bit version 211|----|-----------|
212|`KC_HYPR`|Hold down LCTL + LSFT + LALT + LGUI|
213|`KC_MEH`|Hold down LCTL + LSFT + LALT|
188 214
189### Modifiers with keys 215/* FIXME: Should we have these in QMK too?
216 * |`KC_LCAG`|`LCTL` + `LALT` + `LGUI`|
217 * |`KC_ALTG`|`RCTL` + `RALT`|
218 * |`KC_SCMD`/`KC_SWIN`|`LGUI` + `LSFT`|
219 * |`KC_LCA`|`LCTL` + `LALT`|
220 */
190 221
191* `LCTL(kc)` LCTL + kc 222## Modifiers with keys
192* `LSFT(kc)`/`S(kc)` LSFT + kc
193* `LALT(kc)` LALT + kc
194* `LGUI(kc)` LGUI + kc
195* `RCTL(kc)` RCTL + kc
196* `RSFT(kc)` RSFT + kc
197* `RALT(kc)` RALT + kc
198* `RGUI(kc)` RGUI + kc
199 223
200* `HYPR(kc)` LCTL + LSFT + LALT + LGUI + kc 224|Name|Description|
201* `MEH(kc)` LCTL + LSFT + LALT + kc 225|----|-----------|
202* `LCAG(kc)` LCTL + LALT + LGUI + kc 226|`LCTL(kc)`|`LCTL` + `kc`|
203* `ALTG(kc)` RCTL + RALT + kc 227|`LSFT(kc)`/`S(kc)`|`LSFT` + `kc`|
204* `SCMD(kc)`/`SWIN(kc)` LGUI + LSFT + kc 228|`LALT(kc)`|`LALT` + `kc`|
205* `LCA(kc)` LCTL + LALT + kc 229|`LGUI(kc)`|`LGUI` + `kc`|
230|`RCTL(kc)`|`RCTL` + `kc`|
231|`RSFT(kc)`|`RSFT` + `kc`|
232|`RALT(kc)`|`RALT` + `kc`|
233|`RGUI(kc)`|`RGUI` + `kc`|
234|`HYPR(kc)`|`LCTL` + `LSFT` + `LALT` + `LGUI` + `kc`|
235|`MEH(kc)`|`LCTL` + `LSFT` + `LALT` + `kc`|
236|`LCAG(kc)`|`LCTL` + `LALT` + `LGUI` + `kc`|
237|`ALTG(kc)`|`RCTL` + `RALT` + `kc`|
238|`SCMD(kc)`/`SWIN(kc)`|`LGUI` + `LSFT` + `kc`|
239|`LCA(kc)`|`LCTL` + `LALT` + `kc`|
206 240
207* `OSM(mod)` use mod for one keypress - use mod bits with this 241## One Shot Keys
208 242
209> Mod bits are the 4-letter part of the keycode prefixed with `MOD_`, e.g. `MOD_LCTL` 243Most modifiers work by being held down while you push another key. You can use `OSM()` to setup a "One Shot" modifier. When you tap a one shot mod it will remain is a pressed state until you press another key.
210 244
211### Mod-tap keys 245To specify a your modifier you need to pass the `MOD` form of the key. For example, if you want to setup a One Shot Control you would use `OSM(MOD_LCTL)`.
246
247|Name|Description|
248|----|-----------|
249|`OSM(mod)`|use mod for one keypress|
250|`OSL(layer)`|switch to layer for one keypress|
251
252## Mod-tap keys
212 253
213These keycodes will press the mod(s) when held, and the key when tapped. They only work with [basic keycodes](basic_keycodes.md). 254These keycodes will press the mod(s) when held, and the key when tapped. They only work with [basic keycodes](basic_keycodes.md).
214 255
215* `CTL_T(kc)`/`LCTL_T(kc)` LCTL when held, kc when tapped 256|Name|Description|
216* `RCTL_T(kc)` RCTL when held, kc when tapped 257|----|-----------|
217 258|`CTL_T(kc)`/`LCTL_T(kc)`|`LCTL` when held, `kc` when tapped|
218* `SFT_T(kc)`/`LSFT_T(kc)` LSFT when held, kc when tapped 259|`RCTL_T(kc)`|`RCTL` when held, `kc` when tapped|
219* `RSFT_T(kc)` RSFT when held, kc when tapped 260|`SFT_T(kc)`/`LSFT_T(kc)`|`LSFT` when held, `kc` when tapped|
220 261|`RSFT_T(kc)`|`RSFT` when held, `kc` when tapped|
221* `ALT_T(kc)`/`LALT_T(kc)` LALT when held, kc when tapped 262|`ALT_T(kc)`/`LALT_T(kc)`|`LALT` when held, `kc` when tapped|
222* `RALT_T(kc)`/`ALGR_T(kc)` RALT when held, kc when tapped 263|`RALT_T(kc)`/`ALGR_T(kc)`|`RALT` when held, `kc` when tapped|
223 264|`GUI_T(kc)`/`LGUI_T(kc)`|`LGUI` when held, `kc` when tapped|
224* `GUI_T(kc)`/`LGUI_T(kc)` LGUI when held, kc when tapped 265|`RGUI_T(kc)`|`RGUI` when held, `kc` when tapped|
225* `RGUI_T(kc)` RGUI when held, kc when tapped 266|`C_S_T(kc)`|`LCTL` + `LSFT` when held, `kc` when tapped|
226 267|`MEH_T(kc)`|`LCTL` + `LSFT` + `LALT` when held, `kc` when tapped|
227* `C_S_T(kc)` LCTL + LSFT when held, kc when tapped 268|`LCAG_T(kc)`|`LCTL` + `LALT` + `LGUI` when held, `kc` when tapped|
228* `MEH_T(kc)` LCTL + LSFT + LALT when held, kc when tapped 269|`RCAG_T(kc)`|`RCTL` + `RALT` + `RGUI` when held, `kc` when tapped|
229* `LCAG_T(kc)` LCTL + LALT + LGUI when held, kc when tapped 270|`ALL_T(kc)`|`LCTL` + `LSFT` + `LALT` + `LGUI` when held, `kc` when tapped [more info](http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/)|
230* `RCAG_T(kc)` RCTL + RALT + RGUI when held, kc when tapped 271|`SCMD_T(kc)`/`SWIN_T(kc)`|`LGUI` + `LSFT` when held, `kc` when tapped|
231* `ALL_T(kc)` LCTL + LSFT + LALT + LGUI when held, kc tapped [more info](http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/) 272|`LCA_T(kc)`|`LCTL` + `LALT` when held, `kc` when tapped|
232* `SCMD_T(kc)`/`SWIN_T(kc)` LGUI + LSFT when held, kc when tapped 273
233* `LCA_T(kc)` LCTL + LALT when held, kc when tapped 274# US ANSI Shifted symbols
234 275
235## Shifted symbols 276These keycodes correspond to characters that are "shifted" on a standard US ANSI keyboards. They do not have dedicated keycodes but are instead typed by holding down shift and then sending a keycode.
236 277
237It's important to remember that all of the keycodes also send a left shift - this may cause unintended actions if unaccounted for. The 4-letter code is preferred in most situations. 278It's important to remember that all of these keycodes send a left shift - this may cause unintended actions if unaccounted for. The short code is preferred in most situations.
238 279
239* `KC_TILD`/`KC_TILDE` tilde `~` 280|Short Name|Long Name|Description|
240* `KC_EXLM`/`KC_EXCLAIM` exclamation mark `!` 281|----------|---------|-----------|
241* `KC_AT` at sign `@` 282|`KC_TILD`|`KC_TILDE`|tilde `~`|
242* `KC_HASH` hash sign `#` 283|`KC_EXLM`|`KC_EXCLAIM`|exclamation mark `!`|
243* `KC_DLR`/`KC_DOLLAR` dollar sign `$` 284|`KC_AT`||at sign `@`|
244* `KC_PERC`/`KC_PERCENT` percent sign `%` 285|`KC_HASH`||hash sign `#`|
245* `KC_CIRC`/`KC_CIRCUMFLEX` circumflex `^` 286|`KC_DLR`|`KC_DOLLAR`|dollar sign `$`|
246* `KC_AMPR`/`KC_AMPERSAND` ampersand `&` 287|`KC_PERC`|`KC_PERCENT`|percent sign `%`|
247* `KC_ASTR`/`KC_ASTERISK` asterisk `*` 288|`KC_CIRC`|`KC_CIRCUMFLEX`|circumflex `^`|
248* `KC_LPRN`/`KC_LEFT_PAREN` left parenthesis `(` 289|`KC_AMPR`|`KC_AMPERSAND`|ampersand `&`|
249* `KC_RPRN`/`KC_RIGHT_PAREN` right parenthesis `)` 290|`KC_ASTR`|`KC_ASTERISK`|asterisk `*`|
250* `KC_UNDS`/`KC_UNDERSCORE` underscore `_` 291|`KC_LPRN`|`KC_LEFT_PAREN`|left parenthesis `(`|
251* `KC_PLUS` plus sign `+` 292|`KC_RPRN`|`KC_RIGHT_PAREN`|right parenthesis `)`|
252* `KC_LCBR`/`KC_LEFT_CURLY_BRACE` left curly brace `{` 293|`KC_UNDS`|`KC_UNDERSCORE`|underscore `_`|
253* `KC_RCBR`/`KC_RIGHT_CURLY_BRACE` right curly brace `}` 294|`KC_PLUS`||plus sign `+`|
254* `KC_LT`/`KC_LABK`/`KC_LEFT_ANGLE_BRACKET` left angle bracket `<` 295|`KC_LCBR`|`KC_LEFT_CURLY_BRACE`|left curly brace `{`|
255* `KC_GT`/`KC_RABK`/`KC_RIGHT_ANGLE_BRACKET` right angle bracket `>` 296|`KC_RCBR`|`KC_RIGHT_CURLY_BRACE`|right curly brace `}`|
256* `KC_COLN`/`KC_COLON` colon `:` 297|`KC_LT`/`KC_LABK`|`KC_LEFT_ANGLE_BRACKET`|left angle bracket `<`|
257* `KC_PIPE` pipe `|` 298|`KC_GT`/`KC_RABK`|`KC_RIGHT_ANGLE_BRACKET`|right angle bracket `>`|
258* `KC_QUES`/`KC_QUESTION` question mark `?` 299|`KC_COLN`|`KC_COLON`|colon `:`|
259* `KC_DQT`/`KC_DOUBLE_QUOTE`/`KC_DQUO` double quote `"` 300|`KC_PIPE`||pipe `\|`|
260 301|`KC_QUES`|`KC_QUESTION`|question mark `?`|
261## Layer adjustments 302|`KC_DQT`/`KC_DQUO`|`KC_DOUBLE_QUOTE`|double quote `"`|
262 303
263* `LT(layer, kc)` turn on layer (0-15) when held, kc ([basic keycodes](basic_keycodes.md)) when tapped 304# Layer Changes
264* `TO(layer)` turn on layer when depressed 305
265* `MO(layer)` momentarily turn on layer when depressed (requires `KC_TRNS` on destination layer) 306These are keycodes that can be used to change the current layer.
266* `DF(layer)` sets the base (default) layer 307
267* `TG(layer)` toggle layer on/off 308|Name|Description|
268* `OSL(layer)` switch to layer for one keycode 309|----|-----------|
269* `TT(layer)` tap toggle? idk FIXME 310|`LT(layer, kc)`|turn on layer (0-15) when held, kc ([basic keycodes](basic_keycodes.md)) when tapped|
270 311|`TO(layer)`|turn on layer when depressed|
271## Unicode 312|`MO(layer)`|momentarily turn on layer when depressed (requires `KC_TRNS` on destination layer)|
272 313|`DF(layer)`|sets the base (default) layer|
273* `UNICODE(n)`/`UC(n)` if `UNICODE_ENABLE`, this will send characters up to `0x7FFF` 314|`TG(layer)`|toggle layer on/off|
274* `X(n)` if `UNICODEMAP_ENABLE`, also sends unicode via a different method \ No newline at end of file 315|`TT(layer)`|tap toggle? idk FIXME|
316|`OSL(layer)`|switch to layer for one keycode|
317
318# Unicode
319
320These keycodes can be used in conjuction with the [Unicode](unicode_and_additional_language_support.md) support.
321
322|`UNICODE(n)`/`UC(n)`|if `UNICODE_ENABLE`, this will send characters up to `0x7FFF`|
323|`X(n)`|if `UNICODEMAP_ENABLE`, also sends unicode via a different method|
324
325# `SAFE_RANGE`, or safely defining custom keycodes
326
327Sometimes you want to define your own custom keycodes to make your keymap easier to read. QMK provides `SAFE_RANGE` to help you do that. `SAFE_RANGE` is the first available keycode in the `0x0000`-`0xFFFF` range and you can use it when creating your own custom keycode enum:
328
329```
330enum my_keycodes {
331 FOO = SAFE_RANGE,
332 BAR
333};
334```
335
336You can then use `process_record_user()` to do something with your keycode:
337
338```
339bool process_record_user(uint16_t keycode, keyrecord_t *record) {
340 switch (keycode) {
341 case FOO:
342 // Do something here
343 break;
344 case BAR:
345 // Do something here
346 break;
347 }
348}
349```