The Mod-Tap key
MT(mod, kc) acts like a modifier when held, and a regular keycode when tapped. In other words, you can have a key that sends Escape when you tap it, but functions as a Control or Shift key when you hold it down.
The modifiers this keycode and
OSM() accept are prefixed with
Left GUI (Windows/Command/Meta key)
Right Alt (AltGr)
Right GUI (Windows/Command/Meta key)
Hyper (Left Control, Shift, Alt and GUI)
Meh (Left Control, Shift, and Alt)
You can combine these by ORing them together like so:
MT(MOD_LCTL | MOD_LSFT, KC_ESC)
This key would activate Left Control and Left Shift when held, and send Escape when tapped.
For convenience, QMK includes some Mod-Tap shortcuts to make common combinations more compact in your keymap:
Left Control when held,
Left Shift when held,
Left Alt when held,
Left GUI when held,
Right Control when held,
Right Shift when held,
Right Alt when held,
Right GUI when held,
Left Shift and GUI when held,
Left Control and Alt when held,
Left Shift and Alt when held,
Right Shift and Right Alt (AltGr) when held,
Right Control and Right Shift when held,
Left Control, Alt and GUI when held,
Right Control, Alt and GUI when held,
Left Control and Shift when held,
Left Control, Shift and Alt when held,
Left Control, Shift, Alt and GUI when held,
kc argument of
MT() is limited to the Basic Keycode set, meaning you can't use keycodes like
KC_TILD, or anything greater than
0xFF. This is because QMK uses 16-bit keycodes, of which 3 bits are used for the function identifier, 1 bit for selecting right or left mods, and 4 bits to tell which mods are used, leaving only 8 bits for the keycode. Additionally, if at least one right-handed modifier is specified in a Mod-Tap, it will cause all modifiers specified to become right-handed, so it is not possible to mix and match the two - for example, Left Control and Right Shift would become Right Control and Right Shift.
Expanding this would be complicated, at best. Moving to a 32-bit keycode would solve a lot of this, but would double the amount of space that the keymap matrix uses. And it could potentially cause issues, too. If you need to apply modifiers to your tapped keycode, Tap Dance can be used to accomplish this.
You may also run into issues when using Remote Desktop Connection on Windows. Because these keycodes send key events faster than a human, Remote Desktop could miss them. To fix this, open Remote Desktop Connection, click on "Show Options", open the the "Local Resources" tab, and in the keyboard section, change the drop down to "On this Computer". This will fix the issue, and allow the characters to work correctly. It can also be mitigated by increasing
See the Tap-Hold Configuration Options for additional flags that tweak Mod-Tap behavior.