KC_TRNSto allow keypresses to pass through to lower layers. When using momentary layer switching with MO(), LM(), TT(), or LT(), make sure to leave the key on the above layers transparent or it may not work as intended.
DF(layer)- switches the default layer. The default layer is the always-active base layer that other layers stack on top of. See below for more about the default layer. This might be used to switch from QWERTY to Dvorak layout. (Note that this is a temporary switch that only persists until the keyboard loses power. To modify the default layer in a persistent way requires deeper customization, such as calling the
set_single_persistent_default_layerfunction inside of process_record_user.)
MO(layer)- momentarily activates layer. As soon as you let go of the key, the layer is deactivated.
LM(layer, mod)- Momentarily activates layer (like
MO), but with modifier(s) mod active. Only supports layers 0-15 and the left modifiers:
MOD_LGUI(note the use of
MOD_constants instead of
KC_). These modifiers can be combined using bitwise OR, e.g.
LM(_RAISE, MOD_LCTL | MOD_LALT).
LT(layer, kc)- momentarily activates layer when held, and sends kc when tapped. Only supports layers 0-15.
TG(layer)- toggles layer, activating it if it's inactive and vice versa
TO(layer)- activates layer and de-activates all other layers (except your default layer). This function is special, because instead of just adding/removing one layer to your active layer stack, it will completely replace your current active layers, uniquely allowing you to replace higher layers with a lower one. This is activated on keydown (as soon as the key is pressed).
TT(layer)- Layer Tap-Toggle. If you hold the key down, layer is activated, and then is de-activated when you let go (like
MO). If you repeatedly tap it, the layer will be toggled on or off (like
TG). It needs 5 taps by default, but you can change this by defining
TAPPING_TOGGLE-- for example,
#define TAPPING_TOGGLE 2to toggle on just two taps.
LT()is limited to layers 0-15, and the
kcargument 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 4 bits are used for the function identifier and 4 bits for the layer, leaving only 8 bits for the keycode.
KC_TRNS. As a result if you activate a layer that is numerically lower than your current layer, and your current layer (or another layer that is active and higher than your target layer) has something other than
KC_TRNS, that is the key that will be sent, not the key on the layer you just activated. This is the cause of most people's "why doesn't my layer get switched" problem.
layer_onactivates a layer, and
layer_offdeactivates it. More layer-related functions can be found in action_layer.h.