zmkfirmware / zmk

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

Combine Layer-tap and To Layer #2298

Closed akira-toriyama closed 2 months ago

akira-toriyama commented 2 months ago

Hello

I would like to make the following settings.

But &to BAR_LAYER doesn't work properly. Is there a way to specify &to BAR_LAYER second?

  keymap {
    compatible = "zmk,keymap";

    default_layer {
      bindings = <
        &lt FOO_LAYER &to BAR_LAYER

    FOO_LAYER {
      bindings = < ...

    BAR_LAYER {
      bindings = < ...
caksoylar commented 2 months ago

Hi, the hold-tap behaviors are defined with fixed behaviors (e.g. &kp for key-press, &mo for layer change) for hold and tap. As the info box in https://zmk.dev/docs/behaviors/layers#layer-tap states, layer-tap is a hold-tap with &mo and &kp as its binding types, hence you cannot use it with a &to behavior instead of &kp.

You need to define a new hold-tap behavior with the appropriate bindings, e.g. bindings = <&mo>, <&to>;. See the third example in https://zmk.dev/docs/behaviors/hold-tap#example-use-cases, that will be very close to what you want to do.

(Also closing this because it is a user question; you can follow up here if you need to but we'd encourage you to ask user questions at our community Discord server.)