rvaiya / keyd

A key remapping daemon for linux.
MIT License
3k stars 175 forks source link

[BUG]: shift+altgr ≠ altgr+shift #823

Closed summerhays closed 2 months ago

summerhays commented 2 months ago

This is a strange bug, and I'm pretty sure I'm not the first to report it.

Here's my code:

[main]
rightalt = layer(alterG)
shift = layer(shiftcustom)

# Shift key
[shiftcustom:S]
rightalt = layer(engintlSG)

[alterG:G]
shift = layer(shiftyG)

[shiftyG:S-G]
# A = À (unicode c0)
a = macro(C-S-u c0 space)

When I press and hold, in this order, (either)shift THEN altgr THEN a, I get the result I expect: À. However, when I press and hold, in this order, altgr THEN (either)shift THEN a, I get something strange: ©’ . (it keyd listen it comes out as ^[[218;6u©’

This is the case for many different keys.

Even more strange, when I look at the result of keyd listen, I do get to shiftyG via either path (shift first or AltGr first).

FYI I use linux, and this is happening on all programs.

What I'd like is to get the same result whether I press shift first or AltGr first.

EricZhang456 commented 2 months ago

This is intended behavior. Shift + AltGr and AltGr + Shift triggers different keys under X.

https://en.wikipedia.org/wiki/Compose_key#X_Window_System

summerhays commented 2 months ago

That's not the issue with the bug I'm underlining. In other words, I never said that Shift + AltGr should give the same result as AltGr + Shift. If you look at the code, you'll see that I accounted for both cases. In that code, unless I'm missing something, both distinct paths should lead to the same place, but they don't.

summerhays commented 2 months ago

Ah, well, ok I did solve the issue though, using a composite layer.

Here's the working answer:

[main]
rightalt = layer(alterG)
shift = layer(shiftcustom)

# Shift key
[shiftcustom:S]
## Delete the following line
# rightalt = layer(engintlSG)

[alterG:G]
## Delete the following line
# shift = layer(shiftyG)

## Cannot be its own layername. [shiftyG:S-G]. Has to use a composite layer, like so:
[shiftcustom+alterG:S-G]
# A = À (unicode c0)
a = macro(C-S-u c0 space)