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

Mapping multiple keys to other keys #6

Open
adamschoenemann opened this issue Aug 16, 2018 · 4 comments
Open

Mapping multiple keys to other keys #6

adamschoenemann opened this issue Aug 16, 2018 · 4 comments

Comments

@adamschoenemann
Copy link

Hi, it's me again! The only thing I'm missing now is the ability to map a key with multiple modifiers to another key. That is, I for example have mapped Caps+p to { which works fine, but I'd also like to map Caps+Alt+p to [. I suppose one way to do it would be an extra overlay with "Caps+Alt", which would be fine for me as long as you could have many overlays.

Thanks again!

@svenlr
Copy link
Owner

svenlr commented Aug 17, 2018

Hello again!
I implemented your suggestion on the restricting-modifier-keys branch, at least in the command overlay (which is used if "mapped_sequences" is specified).
This is how your example would look like in config.json (please remove the other entry with "key_code": 33 first). Note that I did not commit it to the branch this time.

      {
        "key_code": 33,
        "mapped_sequences": {
          "down": [
            {"key": "braceleft"}
          ],
          "if_modifiers": {
            "Alt": {
              "down": [
                {"key": "bracketleft"}
              ]
            }
          }
        }
      }

Why we have to use the command overlay for now for modifiers:
It would be a lot more complicated to implement it in the overlay in the system keyboard configuration (xkb) directly, which I am doing right now for simple "mapped_key_label" and "mapped_key_sym".
As far as I understand, only two xkb overlays are supported. However, on my system, only one actually worked.
I will try to do more with the system keyboard configuration when I have time.

TL;DR: python-xlib required for this solution.

@adamschoenemann
Copy link
Author

Impressive! I don't have time to test it out right now, but I will get around to it soon. Again, thanks for the swift turnaround.

@adamschoenemann
Copy link
Author

It works! Good work! Although I've discovered that using "mapped_sequences" the "key" values are interpreted back to a keycode using the keyboard layout of the actual keyboard. For example, right now I'm on a computer whose hardware keyboard is US, but I'm using a Danish keyboard layout, and therefore the "braceleft" keysym maps to "å" (since the keyboard has the "{" key where a Danish layout has "å"). It seems to work fine when using "mapped_keysym", so it's only a problem with "mapped_sequences". But I managed to work around it by using modifiers :)

@svenlr
Copy link
Owner

svenlr commented Aug 20, 2018

This seems to happen because a single key_code can generate multiple keysyms. It is possible to get the key_code that generates a given keysym (this is what I am doing), but I have not found out until now how to get the required modifiers, given the keysym.
I will get back to this in a few weeks.

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

2 participants