zmk-cheat-sheet

ZMK Cheat Sheet

Key Codes

All Codes

Each key’s codes are above page.

Modifiers Functions

xx(code) adds modifier key to the code. They can be comined. &kp LC(RA(B)) = Ctrl+Alt+b.

Modifier functions

Behaviors

Key Press Behaviors

&kp key

press the key.

Momentary layer

&mo layer

momentary activate specified layer.

To Layer

&to layer

Enable the layer and the default layer, and disable all other layers. (maybe it for &trans behavior).

Toggle Layer

&tog layer

Enable the layer until the layer is disabled.

Key Toggle Behavior

&kt key

toggle the key hold or released.

Sticky Key Behavior

&sk key

Stick the key till next key pressed.

Sticky Layer Behavior

&sl layer

Stick the layer till next key pressed.

The devicetree document is here.

Transparent

&trans

Pass down to the next active layer in the stack.

None

&none

No behavior.

Caps Word Behavior

&caps_word

Capitalize till stop key pressed. stop key is not alphabet and continue-list.

The devicetree document is here.

Key Repeat Behavior

&key_repeat

Repeats the last key.

The devicetree document is here.

Conditional Layers

    conditional_layers {
        compatible = "zmk,conditional-layers";
        tri_layer {
            if-layers = <1 2>;
            then-layer = <3>;
        };
    };

If some multiple layers are enabled (in above example, 1 and 2), the then-layer (3) will be enabled.

Hold-Tap Behavior

Advanced Mod-Tap and Layer-Tap.

released within tapping-term-ms, sends tap key. hold after the time, sends (holds) the hold key.

    behaviors {
        key: name {
            compatible = "zmk,behavior-hold-tap";
            label = "LABEL";
            #binding-cells = <2>;
            tapping-term-ms = <200>;
            quick-tap-ms = <0>;
            flavor = "flavor";
            bindings = <hold>, <tap>;
        };
    };

flavor in (hold-preferred, balanced, tap-preferred, tap-unless-interrupted) <hold>, <tap> is behavior like <&kp>, <&mo>.

The devicetree document is here.

Mod-Tap Behavior

&mt modkey tapkey

hold to send modkey, tap to send tapkey.

This behavior equals the Hold-tap “hold-preferred” with (hold = key press(&kp), tap = key press(&kp)).

    behaviors {
        mt_impl: mod-tap-by-hold-tap {
            compatible = "zmk,behavior-hold-tap";
            label = "MOD_TAP_BY_HOLD_TAP";
            #binding-cells = <2>;
            tapping-term-ms = <200>;
            quick-tap-ms = <0>;
            flavor = "hold-preferred";
            bindings = <&kp>, <&kp>;
        };
    };

    // &mt modkey tapkey = &mt_impl modkey tapkey

Layer-tap

&lt layer key

tap sends the key, holds activate the layer.

This behavior equals the Hold-tap “tap-preferred” with (hold = momentary layer(&mo), tap = key press(&kp)).

    behaviors {
        lt_impl: layer-tap-by-hold-tap {
            compatible = "zmk,behavior-hold-tap";
            label = "LAYER_TAP_BY_HOLD_TAP";
            #binding-cells = <2>;
            tapping-term-ms = <200>;
            quick-tap-ms = <0>;
            flavor = "tap-preferred";
            bindings = <&mo>, <&kp>;
        };
    };

    // &lt layer key = &lt_impl layer key

Other definitions

Mod-Morph Behavior

    behaviors {
        key: name {
            compatible = "zmk,behavior-mod-morph";
            label = "LABEL";
            #binding-cells = <0>;
            bindings = <without mod behavior>, <with mod behavior>;
            mods = <(MOD_LGUI|MOD_LSFT|MOD_RGUI|MOD_RSFT)>;
            keep-mods = <(MOD_LSFT)>;
        };
    };

with MOD_* sends with mod behavior, without MOD_* sends the without mod behavior.

Available mods: MOD_LSFT, MOD_RSFT, MOD_LCTL, MOD_RCTL, MOD_LALT, MOD_RALT, MOD_LGUI, MOD_RGUI.

keep-mods’ MOD_* will be keep holding with behavior.

The devicetree document is here.

Tap-Dance Behavior

    behaviors {
        td0: tap_dance_0 {
            compatible = "zmk,behavior-tap-dance";
            label = "TAP_DANCE_0";
            #binding-cells = <0>;
            tapping-term-ms = <200>;
            bindings = <&kp N1>, <&kp N2>, <&kp N3>;
        };
    };

Change behavior by the count of tap.

The devicetree document is here.

Macro Behavior

    macros {
        zed_em_kay: zed_em_kay {
            label = "ZM_zed_em_kay";
            compatible = "zmk,behavior-macro";
            #binding-cells = <0>;
            bindings
                = <&macro_press &kp LSHFT>
                , <&macro_tap &kp Z &kp M &kp K>
                , <&macro_release &kp LSHFT>
                ;
        };
    };

WIP.

The devicetree document is here.

Reset Behaviors

&reset

Reset with current flashed firmware. (like restart)

Bootloader Reset

&bootloader

Reset to flash new firmware.

Bluetooth Behavior

&bt BT_*

Output Selection Behavior

&out OUT_*

RGB Underglow Behavior

&rgb_ug RGB_*

WIP

Backlight Behavior

&bl BL_*

WIP

Power Management Behaviors

&ext_power EP_*

WIP