Skip to content

Latest commit

 

History

History
142 lines (111 loc) · 2.62 KB

README.md

File metadata and controls

142 lines (111 loc) · 2.62 KB

Non-overlap Behavior

This behavior allows only one key to be pressed at a time.

Build

See Building With Modules.

Edit zmk-config/config/west.yml.

manifest:
  remotes:
    - name: zmkfirmware
      url-base: https://github.com/zmkfirmware
+    - name: nguyendown
+      url-base: https://github.com/nguyendown
  projects:
    - name: zmk
      remote: zmkfirmware
      revision: main
      import: app/west.yml
+    - name: zmk-behavior-non-overlap
+      remote: nguyendown
+      revision: main
  self:
    path: config

Keymap

The default Non-overlap instance &nkp uses key press binding &kp. Any keycode from the usage page should work.

Add this to .keymap to use &nkp.

#include <behaviors.dtsi>
+#include <behaviors/non_overlap.dtsi>
#include <dt-bindings/zmk/keys.h>

The following keymap prevents A and D from overlapping each other.

/ {
    keymap {
        default_layer {
            bindings = <
                &kp  Q &kp W &kp  E
                &nkp A &kp S &nkp D>;
        };
    };
};

For W and S, create a new Non-overlap instance. See Multiple instances

Config

resume-capacity

Non-overlap behavior tries to resume any remaining pressed keys in the exact order they were pressed. resume-capacity limits the number of keys this behavior can resume. The default is 9.

In this example, when you press in sequence ASDF and then release them in reverse order FDSA, only D is resumed.

&nkp {
    resume-capacity = <1>;
};

/ {
    keymap {
        default_layer {
            bindings = <
                &nkp A &nkp S
                &nkp D &nkp F>;
        };
    };
};

no-resume

When no-resume is set, the behavior will not resume any remaining pressed keys and the property resume-capacity is ignored.

&nkp {
    no-resume;
};

/ {
    keymap {
        ...
    };
};

You can also set resume-capacity = <0> to achieve the same effect.

Multiple instances

The following example creates a new Non-overlap instance that works separately from the default &nkp.

/ {
    behaviors {
        nkp2: nkp2 {
            compatible = "zmk,behavior-non-overlap";
            #binding-cells = <1>;
            bindings = <&kp>;
        };
    };

    keymap {
        default_layer {
            bindings = <
                &kp  Q &nkp2 W &kp  E
                &nkp A &nkp2 S &nkp D>;
        };
    };
};

Test

cd path/to/zmk-behavior-non-overlap
scripts/run-test.sh

For a specific test case.

scripts/run-test.sh tests/wasd