Tri-state layers are a neat QMK feature that allows you to access a third layer by activating two other layers.
In many keymaps, you'll find a number of layers on the default keymap:
- The Default layer is the base layer and is always active. Here you'll find the most common keys: the letters, some modifiers and perhaps some symbols or numbers.
- The Lower layer can be used for frequently used keys that are used less often than those on the default layer. Many people put symbols, function keys or navigation keys here.
- The Raise layer can be used for frequently used keys that are used less often than those on the default layer. Many people put symbols, function keys or navigation keys here.
- The Adjust layer is for infrequently used keys, like settings to adjust the RGB color or brightness with on your keyboard.
On those keymaps, there's often a bit of code that will allow you to hold both the Lower and Raise layer keys to activate the third, Adjust layer.
What makes it work?
There's a bit of code in your keymap that will look like this:
layer_state_t layer_state_set_user(layer_state_t state) {
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
}
These few lines will look at the status of your layers, and when it sees both the _LOWER
and _RAISE
layer being active, it'll activate the _ADJUST
layer as well.
You'll need to have the _ADJUST
layer be up higher than both the _LOWER
and _RAISE
layers, otherwise this function won't work as intended.
Don't want to use Tri-State layers? Remove the function above from your keymap.
Caveats
Using tri-state layers does mean that you can't access the third layer by itself. If you'd like to use them still, locate the three lines up above and remove them from your keymap. Are you using the configurator? You might want to add another layer and use that instead, since the tri-state code may be hardcoded in your default layout.
Resources
Tri-state layers are further documented on the QMK documentation under Useful Functions.