zmkfirmware / zmk

ZMK Firmware Repository
https://zmk.dev/
MIT License
2.67k stars 2.74k forks source link

How to toggle on and off behaviour (autoshift)? #2276

Closed Nullarity closed 5 months ago

Nullarity commented 5 months ago

Hi, The following behaviour defines my autoshift:

as: auto_shift {
  compatible = "zmk,behavior-hold-tap";
  #binding-cells = <2>;
  flavor = "tap-preferred";
  tapping-term-ms = <155>;
  bindings = <&kp>, <&kp>;
};

.....

default_layer {
bindings = <
AS(TAB) AS(Q) AS(W) ....

.....

For some applications, autoshift is not applicable. So, is it possible to toggle it on/off by pressing a specific key? In QMK, I can do this through AS_TOGG.

I thought I could create a copy of my base layer without AS (...) but neither &to nor &tog to this layer worked as I needed.

Thank you!

caksoylar commented 5 months ago

There is no such toggle in ZMK, the way to do it is to use a separate layer. Using &to or &tog should work to enable/disable that layer, but do pay attention to the layer ordering. Layers have a priority ordering, going from last defined to first defined, where the highest priority layer that is currently active intercepts the key stroke. In this case you should place this new layer right after the default, then you can toggle it on/off with &tog 1.

Nullarity commented 5 months ago

but do pay attention to the layer ordering

Aha, this is what I missed. It works now, thank you!