chordsv2 processing order does not work for target layer of `tap-hold` if disabled in current layer
Requirements
- I've searched platform-specific issues, issues and discussions to see if this has been reported before.
- My issue does not involve multiple simultaneous key presses, OR it does but I've confirmed it is not key rollover or ghosting.
Describe the bug
I have a chordsv2 definition set up that I only want to work in one layer. It fires a vkey that outputs a character (per https://jtroo.github.io/config.html#chordsv2-processing-order). The layer that this chord is active on is accessed via the hold of a tap-hold-press.
If I hold that key and quickly press my chord, it does not fire. This is because I am technically not in that next layer, so the chord is still inactive.
Relevant kanata config
(defcfg
process-unmapped-keys yes
delegate-to-first-layer yes
concurrent-tap-hold yes
chords-v2-min-idle 5
)
(defvirtualkeys
;; https://jtroo.github.io/config.html#chordsv2-processing-order
left-paren S-9
right-paren S-0
)
(defchordsv2
(w e) (multi (on-press press-vkey left-paren) (on-press release-vkey left-paren)) 40 first-release (base)
(i o) (multi (on-press press-vkey right-paren) (on-press release-vkey right-paren)) 40 first-release (base)
)
(defsrc)
(deflayermap (base) ;; high hold timeout to showcase bug
ralt (tap-hold-press 0 1000 ret (layer-while-held numsym))
)
(deflayermap (numsym)
a 1 s 2 d 3 f 4 g 5 h 6 j 7 k 8 l 9 ; 0
)To Reproduce
Run the config above. Hold ralt and press we or io together before the 1000ms expires. Output is your original alpha characters instead of parentheses. If you wait the full second, the chord becomes active and you can use it normally.
Expected behavior
Chords output the parens.
Kanata version
1.12.0
Debug logs
Operating system and I/O mechanism
Linux
Additional context
Per the docs, I completely understand why the config is behaving this way. But externally, it feels unintuitive. If my tap-hold-press's hold function activates a layer, any key I press while holding it is that new layer's key. Chords being treated differently is unexpected.
For my specific config (and maybe others?) I have found a workaround. I created a dummy layer via deflayermap that is completely transparent. My layer key is now a multi that switches into that dummy layer where chords are not disabled. The chord then activates the original target layer as well, as chords do seem to count as the press that enables the hold of my tap-hold-press. I haven't had a lot of testing time yet, but it does seem to work well for tap-hold-press. While the logic of this fix isn't bullet-proof for tap-hold-release variants, I believe that in practical terms it would still be almost impossible to misfire a chord by accidentally rolling to two other keys out of that tap-hold-release.
I filed this as a bug, but if you feel like this is the correct implementation (or just not worth fixing with the easy workaround, both totally valid!) then I would happily volunteer to write up a small paragraph and an example for the docs instead.
Source: jtroo/kanata