rbreaves / kinto

Mac-style shortcut keys for Linux & Windows.
http://kinto.sh
GNU General Public License v2.0
4.25k stars 213 forks source link

Custom shortcut for KEY_EURO and KEY_DOLLAR not working #762

Closed sebastian-ruiz closed 1 year ago

sebastian-ruiz commented 1 year ago

Describe the bug I have a Dutch Apple Magic keyboard With this layout I want to type the euro symbol (€) with alt + shift+2 I add this to kinto.py:

K('Alt-Shift-KEY_2'):K('KEY_EURO')

When I try and use my shortcut, nothing happens. Also nothing happens if I try KEY_DOLLAR.

For debugging I try: K('Alt-Shift-KEY_2'):K('w') and I get the letter w when I type alt + shift + 2.

So I think something is wrong with KEY_EURO and KEY_DOLLAR.

Thanks for your help!

Install Type: Bare Metal Distro: Ubuntu 20.04 DE: Gnome Branch: master Commit: version: 1.2-13 build e106710

RedBearAK commented 1 year ago

@sebastian-ruiz

Unfortunately the Python module that actually "types" the remapped output keystrokes (evdev) doesn't have any knowledge of the keyboard layout. So it always acts like it's typing on a US keyboard layout. The KEY_EURO and KEY_DOLLAR key codes are probably not what you should be trying to use.

If you disable Kinto and then type a Euro character as you normally would on that physical keyboard, which physical keys do you use? If you then map onto those keys as the output from your Alt+Shift+Key_2 input, it should result in the Euro character, exactly the same as when you pressed those keys yourself without Kinto running.

sebastian-ruiz commented 1 year ago

Thank you, this helped me fix the problem!

My config is like this:

K('Alt-Shift-KEY_2'):K('RAlt-Shift-KEY_2'), # map EURO (€) key for NL/EU keyboard
K('Alt-Shift-KEY_3'):K('RAlt-KEY_3'), # map Pound (£) key for NL/EU keyboard
RedBearAK commented 1 year ago

@sebastian-ruiz

As I suspected, this has something to do with the "Alt_Gr" key, which is the key needed to access the special 3rd and 4th characters on some of the keys on international keyboards, and is usually designated to be the "Right Alt" key. Kinto has a feature that allows leaving the Alt key on the right side un-remapped so that it can still be the Alt_Gr key, rather than becoming another Cmd key. But that would only allow these characters to be accessed with the Alt key on the right of the space bar, while these remaps allow either Alt key to be used.

FWIW, the remaps that you've implemented correspond (kind of) to what I call Apple's "Option-key special character entry scheme" where they have a bunch of special characters available on all the letter/number/punctuation keyboard keys when you add Option or Shift+Option. I've documented all of the available characters in this scheme here:

https://github.com/RedBearAK/optspecialchars

I've also implemented this Option-key scheme for the US layout and the "ABC Extended" layout, and it should be available as part of the default config in a future release of Kinto. But for now using this new config requires the user to be knowledgeable enough to switch from using xkeysnail to keyszer as the Kinto key remapper. (And using it while using a non-US keyboard layout may be problematic if any of the letter or number keys are not in the usual QWERTY locations. Some of the special characters may not work correctly because of the way this scheme uses the Linux Unicode character entry technique to produce the characters.)

https://github.com/rbreaves/kinto/pull/750

I will need to look into whether the Option-key scheme has all the special characters in the same locations on real Macs while using international layouts. If so, that would be very interesting.

EDIT: Nope. Switching to "ABC - AZERTY" or "Dutch (Belgian)" seems to have the special characters in very different locations. Choosing "Dutch (Dutch)" yields similar results to the US layout, but not quite the same. Unfortunately.