zmk: [BUG] Mod-taps frequently getting stuck

I’ve noticed more and more that my home-row modifier mod-tap keys keep getting stuck from time to time. So I did some analysis.

Assuming both S and L are configured as mod-taps for LSHFT and RSHFT respectively, and D and K are both mod-taps for LGUI. A tapping term of 150 is being used.

the following inputs consistently result in the shift modifier being stuck (which is then only resolvable by hitting reset) HOLD(s), WAIT(200ms), TAP(l), RELEASE(s)

additionally, the following inputs: HOLD(s), WAIT(200ms), TAP(k), RELEASE(s) result in no immediate change, until either d or k (either of the mod-taps for LGUI) are tapped again. As soon as either of them is tapped, the gui modifier starts being stuck as held down.

Looking at the logs, I observed the error message ACTIVE_HOLD_TAP_CLEANED_UP_TOO_EARLY

Here is some more log output (this is showing the first input pattern I describe):

logs
[00:00:51.001,953] <dbg> zmk.zmk_endpoints_send_report: usage page 0x07
[00:00:54.885,833] <dbg> zmk.kscan_matrix_read: Sending event at 1,2 state on
[00:00:54.885,894] <dbg> zmk.zmk_kscan_process_msgq: Row: 1, col: 2, position: 14, pressed: true
[00:00:54.885,925] <dbg> zmk.position_state_changed_listener: 14 bubble (no undecided hold_tap active)
[00:00:54.885,955] <dbg> zmk.position_state_down: combo: capturing position event 14
[00:00:54.885,955] <dbg> zmk.zmk_event_manager_handle_from: Listener captured the event
[00:00:56.227,569] <dbg> zmk.kscan_matrix_read: Sending event at 4,3 state on
[00:00:56.227,630] <dbg> zmk.zmk_kscan_process_msgq: Row: 4, col: 3, position: 21, pressed: true
[00:00:56.227,661] <dbg> zmk.position_state_changed_listener: 21 bubble (no undecided hold_tap active)
[00:00:56.227,691] <dbg> zmk.position_state_down: combo: capturing position event 21
[00:00:56.227,722] <dbg> zmk.release_pressed_keys: combo: releasing position event 14
[00:00:56.227,722] <dbg> zmk.zmk_keymap_apply_position_state: layer: 0 position: 14, binding name: MOD_TAP
[00:00:56.227,752] <dbg> zmk.on_hold_tap_binding_pressed: 14 new undecided hold_tap
[00:00:56.227,783] <dbg> zmk.release_pressed_keys: combo: reraising position event 21
[00:00:56.227,813] <dbg> zmk.decide_hold_tap: 14 decided hold-timer (tap-preferred decision moment timer)
[00:00:56.227,813] <dbg> zmk.on_keymap_binding_pressed: position 14 keycode 0x700e1
[00:00:56.227,874] <dbg> zmk.hid_listener_keycode_pressed: usage_page 0x07 keycode 0xe1 implicit_mods 0x00 explicit_mods 0x00
[00:00:56.227,874] <dbg> zmk.zmk_hid_register_mod: Modifier 1 count 1
[00:00:56.227,874] <dbg> zmk.zmk_hid_register_mod: Modifiers set to 0x02
[00:00:56.227,874] <dbg> zmk.zmk_hid_implicit_modifiers_press: Modifiers set to 0x02
[00:00:56.227,905] <dbg> zmk.zmk_endpoints_send_report: usage page 0x07
[00:00:56.227,966] <dbg> zmk.position_state_changed_listener: 536871936 capturing 21 down event
[00:00:56.227,966] <dbg> zmk.zmk_event_manager_handle_from: Listener captured the event
[00:00:56.227,996] <dbg> zmk.zmk_event_manager_handle_from: Listener captured the event
[00:00:56.351,837] <dbg> zmk.kscan_matrix_read: Sending event at 4,3 state off
[00:00:56.351,898] <dbg> zmk.zmk_kscan_process_msgq: Row: 4, col: 3, position: 21, pressed: false
[00:00:56.351,928] <dbg> zmk.position_state_changed_listener: 21 bubble (no undecided hold_tap active)
[00:00:56.351,959] <dbg> zmk.zmk_keymap_apply_position_state: layer: 0 position: 21, binding name: MOD_TAP
[00:00:56.351,989] <err> zmk: ACTIVE_HOLD_TAP_CLEANED_UP_TOO_EARLY
[00:00:56.796,051] <dbg> zmk.kscan_matrix_read: Sending event at 1,2 state off
[00:00:56.796,142] <dbg> zmk.zmk_kscan_process_msgq: Row: 1, col: 2, position: 14, pressed: false
[00:00:56.796,173] <dbg> zmk.position_state_changed_listener: 14 bubble (no undecided hold_tap active)
[00:00:56.796,203] <dbg> zmk.zmk_keymap_apply_position_state: layer: 0 position: 14, binding name: MOD_TAP
[00:00:56.796,234] <dbg> zmk.on_keymap_binding_released: position 14 keycode 0x700e1
[00:00:56.796,264] <dbg> zmk.hid_listener_keycode_released: usage_page 0x07 keycode 0xe1 implicit_mods 0x00 explicit_mods 0x00
[00:00:56.796,295] <dbg> zmk.zmk_hid_unregister_mod: Modifier 1 count: 0
[00:00:56.796,295] <dbg> zmk.zmk_hid_unregister_mod: Modifier 1 released
[00:00:56.796,295] <dbg> zmk.zmk_hid_unregister_mod: Modifiers set to 0x00
[00:00:56.796,295] <dbg> zmk.zmk_hid_implicit_modifiers_release: Modifiers set to 0x00
[00:00:56.796,325] <dbg> zmk.zmk_endpoints_send_report: usage page 0x07
[00:00:56.796,386] <dbg> zmk.on_hold_tap_binding_released: 14 cleaning up hold-tap
[00:00:58.210,021] <dbg> zmk.kscan_matrix_read: Sending event at 1,2 state on
[00:00:58.210,083] <dbg> zmk.zmk_kscan_process_msgq: Row: 1, col: 2, position: 14, pressed: true
[00:00:58.210,113] <dbg> zmk.position_state_changed_listener: 14 bubble (no undecided hold_tap active)
[00:00:58.210,144] <dbg> zmk.position_state_down: combo: capturing position event 14
[00:00:58.210,144] <dbg> zmk.zmk_event_manager_handle_from: Listener captured the event
[00:00:58.266,754] <dbg> zmk.kscan_matrix_read: Sending event at 1,2 state off
[00:00:58.266,876] <dbg> zmk.zmk_kscan_process_msgq: Row: 1, col: 2, position: 14, pressed: false
[00:00:58.266,906] <dbg> zmk.position_state_changed_listener: 14 bubble (no undecided hold_tap active)
[00:00:58.266,906] <dbg> zmk.release_pressed_keys: combo: releasing position event 14
[00:00:58.266,906] <dbg> zmk.zmk_keymap_apply_position_state: layer: 0 position: 14, binding name: MOD_TAP
[00:00:58.266,967] <dbg> zmk.on_hold_tap_binding_pressed: 14 new undecided hold_tap
[00:00:58.266,998] <dbg> zmk.zmk_keymap_apply_position_state: layer: 0 position: 14, binding name: MOD_TAP
[00:00:58.267,059] <dbg> zmk.decide_hold_tap: 14 decided tap (tap-preferred decision moment key-up)
[00:00:58.267,059] <dbg> zmk.on_keymap_binding_pressed: position 14 keycode 0x70016
[00:00:58.267,089] <dbg> zmk.hid_listener_keycode_pressed: usage_page 0x07 keycode 0x16 implicit_mods 0x00 explicit_mods 0x00
[00:00:58.267,120] <dbg> zmk.zmk_hid_implicit_modifiers_press: Modifiers set to 0x00
[00:00:58.267,120] <dbg> zmk.zmk_endpoints_send_report: usage page 0x07
[00:00:58.267,181] <dbg> zmk.release_captured_events: Releasing key position event for position 21 pressed
[00:00:58.267,181] <dbg> zmk.position_state_changed_listener: 21 bubble (no undecided hold_tap active)
[00:00:58.267,211] <dbg> zmk.position_state_down: combo: capturing position event 21
[00:00:58.267,211] <dbg> zmk.zmk_event_manager_handle_from: Listener captured the event
[00:00:58.267,242] <dbg> zmk.on_keymap_binding_released: position 14 keycode 0x70016
[00:00:58.267,272] <dbg> zmk.hid_listener_keycode_released: usage_page 0x07 keycode 0x16 implicit_mods 0x00 explicit_mods 0x00
[00:00:58.267,303] <dbg> zmk.zmk_hid_implicit_modifiers_release: Modifiers set to 0x00
[00:00:58.267,303] <dbg> zmk.zmk_endpoints_send_report: usage page 0x07
[00:00:58.275,054] <dbg> zmk.on_hold_tap_binding_released: 14 cleaning up hold-tap
[00:00:58.275,146] <dbg> zmk.release_pressed_keys: combo: releasing position event 21
[00:00:58.275,146] <dbg> zmk.zmk_keymap_apply_position_state: layer: 0 position: 21, binding name: MOD_TAP
[00:00:58.275,177] <dbg> zmk.on_hold_tap_binding_pressed: 21 new undecided hold_tap
[00:00:58.275,238] <dbg> zmk.decide_hold_tap: 21 decided hold-timer (tap-preferred decision moment timer)
[00:00:58.275,268] <dbg> zmk.on_keymap_binding_pressed: position 21 keycode 0x700e5
[00:00:58.275,329] <dbg> zmk.hid_listener_keycode_pressed: usage_page 0x07 keycode 0xe5 implicit_mods 0x00 explicit_mods 0x00
[00:00:58.275,329] <dbg> zmk.zmk_hid_register_mod: Modifier 5 count 1
[00:00:58.275,329] <dbg> zmk.zmk_hid_register_mod: Modifiers set to 0x20
[00:00:58.275,329] <dbg> zmk.zmk_hid_implicit_modifiers_press: Modifiers set to 0x20
[00:00:58.275,329] <dbg> zmk.zmk_endpoints_send_report: usage page 0x07
[00:00:58.603,515] <dbg> zmk.kscan_matrix_read: Sending event at 1,1 state on
[00:00:58.603,576] <dbg> zmk.zmk_kscan_process_msgq: Row: 1, col: 1, posi

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 29 (5 by maintainers)

Commits related to this issue

Most upvoted comments

@elkowar and @okke-formsma. I often get stuck down home row mods (as in, until I reset, that modifier key is permanently being sent to the PC). After some debugging, I can confirm that I have the same <err> tag showing ACTIVE_HOLD_TAP_CLEANED_UP_TOO_EARLY (log line 36), and I have the same corrupted key press number, 536871936 (log line 29), as the original poster.

I can reproduce this by typing in Notepad++ with the left hand (main side of the keyboard), which has - a middle finger on index 15 [&hm LALT S] on Layer 0, and a simple [&kp DOWN] on layer 1. - a pinky finger on index 25 [&lt L1 Z] to go from layer 0 to layer 1. - a combo that includes a key at index 25, with a timeout-ms longer than the tapping-term-ms that is set for the corresponding &lt. my combo is: COMBO(num_one, 5000, 13 25, &kp N1), which sends num 1 when keys at index 13 and 25 are pressed within 5000 ms of each other. 5000ms exaggerated for exploiting this ticket.

To reproduce:

  1. I press the pinky finger (index 25) to go into layer 1, then press the middle finger (index 15). Altogether, this should press the DOWN key.

  2. However, if index 15 is pressed within 5000ms of index 25 being pressed, the DOWN key will not be pressed.

  3. Now all keys can be released, it doesn’t matter what order they are released in.

  4. At this point, if index 15 is tapped, it prints one S, pauses for a quick moment, then prints S’s continually until I hit another key, as if I tapped and then held index 15, the S key.

  5. Regardless of whether you tapped index 15 in step 4, once any home row mod is tapped, the ALT key (the modifier on index 15) is now stuck (held down) until I reset the keyboard. After resetting, I have to hold index 15 (to produce an ALT keystroke) before the computer behaves normally again. Otherwise it behaves as though ALT is still pressed.

Therefore, I can affirm that a combo can affect homerow mod. This behavior was repeatable for other &hm keys, as well as repeatable for keys on the right half.

For now, my work around is to makes sure that my combo timeout-ms is not longer than my &lt tapping-term-ms. I’ve attached my keymap file, and a debug log output of the events on steps 1 and 2.

log.txt corne.keymap.txt

I hope this helps debug this problem!

Curious, anyone here experiencing this that was not connected to more than one profile? I connected to a second profile and started to constantly get the issue. I disconnected from one and it’s been good since. Might be coincidence, but thought I’d ask in case.

That’s a very clean number in binary: 536871936 -> 00100000000000000000010000000000

Makes me wonder if there’s an overflow, max int size, or similar curmudgeonry occurring.

Yea, sorry, I removed them as they where causing too many issues currently ^^ The gui mod-taps where set via the still present behavior:

hmgui: homerow_gui {
      compatible = "zmk,behavior-hold-tap";
      label = "HOMEROW_GUI";
      #binding-cells = <2>;
      tapping-term-ms = <200>;
      quick_tap_ms = QUICK_TAP;
      flavor = "tap-preferred";
      bindings = <&kp>, <&kp>;
    };

and where on the d and k keys