#nest a tap dance inside a mod-tap, as the tap

1 messages · Page 1 of 1 (latest)

lofty hollow
#

I want to create a key that is RCTRL when held, SQT when tapped once, and SEMI when tapped twice.

I used the "Advanced Example: Mod-Tap Nested inside Tap-Dance" from https://zmk.dev/docs/behaviors/tap-dance to create the behavior, but it doesn't work quite right when holding shift (to get the shifted version of SQT or SEMI).
Here is my code:

amr: alpha_mods_r {
    compatible = "zmk,behavior-hold-tap";
    label = "ALPHA_MT_R";
    #binding-cells = <2>;
    tapping-term-ms = <tapping_term_fast>;//<215>;//<250>;
    quick-tap-ms = <quick_tap_term>;//<200>;//<150>;
    flavor = "balanced";
    bindings = <&kp>, <&kp>;
};

td_amr_1: tap_dance_amr_rctrl_sqt_semi {
    compatible = "zmk,behavior-tap-dance";
    label = "TAP_DANCE_AMR_RCTRL_SQT_SEMI";
    #binding-cells = <0>;
    tapping-term-ms = <tapping_term_xfast>;
    bindings = <&amr RCTRL SQT>, <&kp SEMI>;
};

The problem is that unless I hold the shift key down for the entire tapping term, I get the unshifted SQT.
This creates an awkward pause when typing, but if I make the tapping term short enough to fix the problem, it creates a new problem of being impossible to tap quickly enough to get the double-tap.

I think what I need is instead of nesting a mod-tap inside a tap dance, I need to nest a tap dance inside a mod-tap, as the tap.

I tried the following, but found that this isn't supported:

td_r_1: tap_dance_sqt_semi {
    compatible = "zmk,behavior-tap-dance";
    label = "TAP_DANCE_SQT_SEMI";
    #binding-cells = <0>;
    tapping-term-ms = <tapping_term_fast>;
    bindings = <&kp SQT>, <&kp SEMI>;
};

td_amr_1: tap_dance_amr_rctrl_sqt_semi {
    compatible = "zmk,behavior-hold-tap";
    label = "TAP_DANCE_AMR_RCTRL_SQT_SEMI";
    #binding-cells = <2>;
    tapping-term-ms = <tapping_term_slow>;
    quick-tap-ms = <quick_tap_term>;
    flavor = "balanced";
    bindings = <&kp RCTRL>, <&td_r_1>;
};

Does anyone know how to fix this issue? If my idea is correct, but it requires a custom behavior to be created, can someone please help me out on how to create that?

Any help is appreaciated. Thanks.

frail sun
#

Is the shift coming from a hold-tap key itself? Otherwise I am not sure why that would change depending on the key you are interrupting it with. What are the properties of that hold-tap, is it using key positions?

#

For the latter issue (nesting it the other way around), you should use bindings = <&kp>, <&td_r_1>; in td_amr_1 and use it like &td_amr_1 RCTRL 0

lofty hollow
#

Thanks for the reply. The shift keys are hold-taps, but they are configured to prefer holds. Also, I have no issues using shift with any other keys. For some reason the keys using both hod-tap and tap-dance require me to hold shift for the entire tap term for shift to be applied. When you say to use it like "&td_amr_1 RCTRL 0", I have two questions: 1. Does it matter that the order is reversed from the bindings declaration? I was under the impression that the order mattered. 2. Why did you put "0" after RCTRL? Thanks.

frail sun
#

Unless you use positional hold tap wih the shift hold-tap, not sure why the first issue happens

lofty hollow
#

Oh I see. I was thinking of the keymap part incorrectly. Hopefully that works. And, if by "positional" hold-tap, you're referring to the "hold-trigger-key-positions" behavior setting, then no I do not have that set. It also makes me wait for the entire tapping term to use the RCTRL as a hold for shortcuts like CTRL -

#

When I use the same hold-tap without the tap-dance, it works correctly and registers a hold before the end of the tapping term if another key is tapped while it's held down. I'm optimistic switching the order will work. I'll try that as soon as I get a chance.

frail sun
#

I guess it might be a bug with the hold tap interrupt logic that it doesn’t count tap dances as interrupts

lofty hollow
#

I think you're right that the hold-tap interrupt logic doesn’t count tap dances as interrupts. I updated the behavior to what we discussed, but it provides the same result. Is there anything I can do to customize that behavior for my keymap to fix it in my branch? I'd be willing to spend considerable effort on this, since I like my keymap as is, and that lag is getting quite annoying. Although I've done quite a bit with QMK, I'm very new to ZMK, so I just don't know what's possible.

frail sun
#

I am not sure exactly, but I would first check open issues related to tap dances. I feel like I saw a similar issue reported at some point

#

I would look into hold tap code (beware, it’s big), figure out how it checks for interrupts, then see why tap dances might not be triggering

#

If you can reproduce it in a unit test, please open an issue for it as well!

lofty hollow
#

Great thanks I'll check that out, and if I put together something that works, I'll definitely share it. Do you mind giving me a link to the hold tap code? My experience with ZMK so far has only involved creating my own keymap. I haven't looked through the primary ZMK repository yet.

frail sun
#

I think creating a unit test would be a big help, and someone familiar with the code might pick up from there, too

lofty hollow
#

Thanks! Ok I'll do that. When it says "Copy the test set that most closely resembles the tests you will be creating." Where do I see other test sets?