evremap icon indicating copy to clipboard operation
evremap copied to clipboard

Swap keys

Open tsankuanglee opened this issue 2 years ago • 2 comments

Wonderful utility! Could we add a function to swap keys that doesn't cause loops, i.e. swap KEY_CAPSLOCK and KEY_LEFTCTRL.

For example, I'd like the physical CAPSLOCK key to do the dual_role, and the physical LEFTCTRL to emit CAPSLOCK.

This doesn't work as intended:

[[dual_role]]
input = "KEY_CAPSLOCK"
hold = ["KEY_LEFTCTRL"]
tap = ["KEY_ESC"]

[[remap]]
input = ["KEY_LEFTCTRL"]
output = ["KEY_CAPSLOCK"]

I understand I can do something like:

[[dual_role]]
input = "KEY_CAPSLOCK"
hold = ["KEY_LEFTCTRL"]
tap = ["KEY_ESC"]

[[dual_role]]
input = "KEY_LEFTCTRL"
hold = ["KEY_LEFTCTRL"]
tap = ["KEY_CAPSLOCK"]

But I can still see some use case for a real swapping. Perhaps a way to specify the original "physical" key?

tsankuanglee avatar Mar 14 '22 06:03 tsankuanglee

I have the problem. It seems that keys triggered via hold will not be prevented from matching as input.

So I simply make the hold key to be KEY_RIGHTCTRL, like this

[[dual_role]]
input = "KEY_CAPSLOCK"
hold = ["KEY_RIGHTCTRL"]
tap = ["KEY_ESC"]

[[remap]]
input = ["KEY_LEFTCTRL"]
output = ["KEY_CAPSLOCK"]

ShampooDeng avatar Sep 22 '23 14:09 ShampooDeng

Thank you. These workarounds, including your version and mine, are doable. I chose mine because I have my downstream application that needs to distinguish LEFT-CTRL and RIGHT-CTRL. Either way, I'm still wondering whether this is a feature worth adding -- it's probably unlikely that there's a use case for re-defining a hold/tap output.

tsankuanglee avatar Nov 12 '23 19:11 tsankuanglee