evdevremapkeys
evdevremapkeys copied to clipboard
How can I remap a combination of keys to a single key?
Is it possible to map, e.g. a combination of Ctrl and left arrow keys to the Home key?
If yes, how can I specify that in the YAML configuration?
No, I haven't had this use-case so I didn't implement it.
No, I haven't had this use-case so I didn't implement it.
Ok, I see.
Would it be hard to implement N:1 mappings? I really got accustomed to using Fn + Left for Home and Fn + Fight for End on my Dell XPS 15, so I miss that when I use a regular external keyboard.
It wouldn't be terribly hard - the main thing is you have to make the event mapping logic stateful as you need to track multiple keys being held down, and each of those is a separate event. There's a smaller problem of how you express a combination in the config syntax, but that can be solved for sure.
I'm not particularly motivated to implement this, but I'll happily take a PR for it.
I am also interested in a feature like this.
Maybe the easiest way to implement this is using the following function? http://python-evdev.readthedocs.io/en/latest/tutorial.html#getting-currently-active-keys
if you want to remap Ctrl+s, you could check after each s-event whether the ctrl key is active, and only do the remapping in that case. No idea if this actually could work.
That helps solve the event mapping. Still need to come up with an efficient config expression.
I quickly hacked a way to handle N:N mappings: https://github.com/pronobis/evdevremapkeys
The input keys can be specified as a "tuple" in a config file, e.g.:
remapping:
KEY_F1:
- BTN_LEFT
(KEY_LEFTMETA, KEY_F1):
- KEY_LEFTCTRL
- KEY_F5
All additional keys are simply passed from the input to the output, e.g. Shift+F1 will become Shift+BTN_LEFT and Shift+Meta+F1 will become Shift+Ctrl+F5.
Also, since I needed it, I added some basic functionality that allows remappings to be conditioned on the active window class (for X11 only for now), e.g.:
(KEY_LEFTMETA, KEY_F1, Google-chrome):
Key repeating ('repeat' and 'delay' config options) is not yet implemented/tested for N:N mappings.
happy user of @pronobis fork. please consider a merge. thanks! ;-)
I merged #16 which provides an equivalent capability in a different way, although it doesn't do anything like window mapping. That's beyond the scope of what I want this program to do.
The problem I had with modifier_groups
is that as soon as I define one for say ALT
key, all other combinations won't work anymore (like ALT+TAB
). Fork of @pronobis worked just fine :)
I need a way not just to capture multiple keys, but also to suppress additional scancodes from multiscancode keys. (my HP EliteBook 735 G6 has a very strange keyboard)
I did some work based on @pronobis work here: https://github.com/philipl/evdevremapkeys/issues/22
The problem is you have to wait for all keys pressed to decide whether or not to remap to a single.
SO if you are remapping CTRL+X to "BKSPACE", everytime ctrl is pressed, evedevremapkeys will have to not send the ctrl code on until it sees the next key. So remapping CTRL+X to a single key delays the handling for all CTRL combos. This is true of all N to 1 mappings.
Probably a bug in modifier group handling. My suspicion is if you have a modifier group for Ctrl-A, and you press Ctrl-B, it forgets to send on the original Ctrl code.
The of "Modifiers" doesn't really exist at the event level, so I don't necessarily think this is the best implementation.
What is seen is CTRL-pressed B pressed B released Ctrl-released.
If we had a syntax for supporting A is pressed and then B is pressed vs A pressed B pressed B released A released, we could be a bit more flexible.
Hmm.
@pronobis "All additional keys are simply passed from the input to the output" is it possible to disable this feature?