mooz / xkeysnail

Yet another keyboard remapping tool for X environment
890 stars 112 forks source link

c-h and xcape control as esc conflict #157

Open popeliao opened 2 years ago

popeliao commented 2 years ago

My setup: 1 use xkeysnail to swap capslock and left contrl define_modmap({ Key.CAPSLOCK: Key.LEFT_CTRL }) 2 use xcape to make a single press on capslock become esc xcape -e 'Control_L=Escape' 3 use xkeysnail to map "c-h" as "BACKSPACE" K("C-h"): K("BACKSPACE"),

Issue: even "c-h" is mapped as "BACKSPACE", it also triggers a "esc" as "control" is also somehow sent by xkeysnail.

Workaround: I use left shift as esc at the moment: xcape -e 'Shift_L=Escape'

Question: why is xkeysnail still sends another single "control" when "c-h" is already mapped to "backspace"? I think this is a bug. Anyway, really thanks for this project, xkeysnail really helps me for my transition to linux from macOS

joshgoebel commented 2 years ago

It's not a bug, it's intentional. We deliver keystrokes the moment they are pressed because you never know WHAT might be listening to them (or what will follow)... we don't know when you hit Ctrl that it's part of a Ctrl-h sequence... it might even do something on it's own.

So we press it immediately, then when we see the H we realize it's part of a remapping (that doesn't include it) we release it and then after we type "backspace" (with no modifiers) we immediately press it again... because you might be typing a sequence.

This is common in many apps and can be done without lifting your finger off of control. So that is why holding control really means holding control - before we see any modifiers come across the wire.

joshgoebel commented 2 years ago

FYI: This is already fixed in my fork... I've added the concept of "suspended" keys... keys that you've pressed but (for a period of time) we aren't sure what to do with - because we don't know if you mean the literal key or if you're using them in an entirely different context. If you are comfortable running xkeysnail from source let me know, I could use beta/alpha testers.

joshgoebel commented 2 years ago

@popeliao If you'd want to join the new discussion on this issue at my fork (where I've been trying to fix this):

https://github.com/joshgoebel/keyszer/issues/9

I'd truly like to fix this, but turns out it's a hard problem. Your feedback might be helpful. Please see issue #9 and at least read the recent update, which is a summary. Then if you have any thoughts please share.