Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I remap a combination of keys to a single key? #4

Open
tjanez opened this issue Dec 27, 2017 · 13 comments
Open

How can I remap a combination of keys to a single key? #4

tjanez opened this issue Dec 27, 2017 · 13 comments

Comments

@tjanez
Copy link

tjanez commented Dec 27, 2017

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?

@philipl
Copy link
Owner

philipl commented Dec 27, 2017

No, I haven't had this use-case so I didn't implement it.

@tjanez
Copy link
Author

tjanez commented Dec 29, 2017

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.

@philipl
Copy link
Owner

philipl commented Dec 30, 2017

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.

@TheoRet
Copy link

TheoRet commented Jan 31, 2018

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.

@philipl
Copy link
Owner

philipl commented Feb 19, 2018

That helps solve the event mapping. Still need to come up with an efficient config expression.

@pronobis
Copy link

pronobis commented Jul 25, 2018

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.

@rpodgorny
Copy link

happy user of @pronobis fork. please consider a merge. thanks! ;-)

@philipl
Copy link
Owner

philipl commented Aug 30, 2019

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.

@sjentzsch
Copy link

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 :)

@kolAflash
Copy link

kolAflash commented Jun 5, 2020

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: #22

@DanielJoyce
Copy link
Contributor

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.

@DanielJoyce
Copy link
Contributor

DanielJoyce commented Aug 19, 2020

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.

@cjh9
Copy link

cjh9 commented Apr 18, 2021

@pronobis "All additional keys are simply passed from the input to the output" is it possible to disable this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants