libxkbcommon icon indicating copy to clipboard operation
libxkbcommon copied to clipboard

Windows-style `LevelThree` as `Ctrl+Alt`

Open wismill opened this issue 1 month ago • 1 comments

On Windows the default third-level modifier is actually Ctrl+Alt, while Linux has a dedicated modifier: LevelThree.

While most people would probably use only the AltGr key as third-level modifier, some prefer to use the key combination Ctrl+Alt, either because they do have symmetric Alt keys or because they simply expect AltGr and Ctrl+Alt key combos to be strictly equivalent.

See some use cases on the xkeyboard-config project:

wismill avatar Nov 06 '25 15:11 wismill

My initial idea to tackle this is to implement a dedicated mechanism:

  • Active only on keys that have a key type such that its mask:

    • has LevelThree
    • has at most one of Control or Alt

    The reasoning should be on the modifier encodings.

  • Active only when Ctrl+Alt is in the effective modifier mask.

  • Generate a sequence of 3 events, similar to RedirectKey():

    1. Save the state; remove Ctr+Alt from the modifiers and add LevelThreee and send the corresponding event.
    2. Send the key event.
    3. Restore the state and send the corresponding event.

wismill avatar Nov 06 '25 15:11 wismill