Keyboard shortcuts with crtl + alt gr (like crtl + \) on a German keyboard are not working #20678

Closed
opened 2026-01-31 07:21:00 +00:00 by claunia · 3 comments
Owner

Originally created by @Rilele on GitHub (Oct 14, 2023).

Windows Terminal version

1.20.231013001-experimental or 1.17.11461.0

Windows build number

10.0.19045.3570

Other Software

GNU nano 6.2-1 on Ubuntu 22.04.3 on WSL (also happens with nano from Git for Windows 2.42.0.2 and via SSH)

Steps to reproduce

  1. Ensure your keyboard layout is set to German.
  2. Start WSL
  3. Open nano.
  4. Press Strg + Alt Gr + ß to get Crtl + \ (On a US keyboard with German Layout press: Crtl + Right Alt + -)

Expected Behavior

Nano opens the replace dialog.

Actual Behavior

A \ appears.

Note, that on a German keyboard layout \ is only accessible via Alt Gr + ß or Crtl + Alt + ß. To enter shortcuts like Ctrl + \ a third key is required.
The issue also happens with conshost.exe.

showkey -a shows
\ 92 0134 0x5c
but
^\ 28 0034 0x1b
would be expected.

Originally created by @Rilele on GitHub (Oct 14, 2023). ### Windows Terminal version 1.20.231013001-experimental or 1.17.11461.0 ### Windows build number 10.0.19045.3570 ### Other Software GNU nano 6.2-1 on Ubuntu 22.04.3 on WSL (also happens with nano from Git for Windows 2.42.0.2 and via SSH) ### Steps to reproduce 1. Ensure your keyboard layout is set to German. 2. Start WSL 3. Open nano. 4. Press Strg + Alt Gr + ß to get Crtl + \ (On a US keyboard with German Layout press: Crtl + Right Alt + -) ### Expected Behavior Nano opens the replace dialog. ### Actual Behavior A \ appears. Note, that on a German keyboard layout \ is only accessible via Alt Gr + ß or Crtl + Alt + ß. To enter shortcuts like Ctrl + \ a third key is required. The issue also happens with conshost.exe. showkey -a shows \ 92 0134 0x5c but ^\ 28 0034 0x1b would be expected.
claunia added the Issue-BugIn-PRArea-InputNeeds-Tag-FixProduct-Terminal labels 2026-01-31 07:21:01 +00:00
Author
Owner

@j4james commented on GitHub (Oct 15, 2023):

I believe this is because Windows treats Ctrl+Alt as an alias for AltGr.1 As a result, when you press the AltGr key, what the application actually receives is two keypresses: a Ctrl key followed by an AltGr key. That makes it indistinguishable from when you manually press Ctrl along with AltGr.

That said, it is still possible for you to generate this shortcut on a German keyboard. All the controls that rely on punctuation keys are also accessible via the key combinations Ctrl+3 through Ctrl+7. In particular, Ctrl+4 is the equivalent of Ctrl+\.

@j4james commented on GitHub (Oct 15, 2023): I believe this is because Windows treats <kbd>Ctrl</kbd>+<kbd>Alt</kbd> as an alias for <kbd>AltGr</kbd>.[^ref] As a result, when you press the <kbd>AltGr</kbd> key, what the application actually receives is _two_ keypresses: a <kbd>Ctrl</kbd> key followed by an <kbd>AltGr</kbd> key. That makes it indistinguishable from when you manually press <kbd>Ctrl</kbd> along with <kbd>AltGr</kbd>. That said, it is still possible for you to generate this shortcut on a German keyboard. All the controls that rely on punctuation keys are also accessible via the key combinations <kbd>Ctrl</kbd>+<kbd>3</kbd> through <kbd>Ctrl</kbd>+<kbd>7</kbd>. In particular, <kbd>Ctrl</kbd>+<kbd>4</kbd> is the equivalent of <kbd>Ctrl</kbd>+<kbd>\\</kbd>. [^ref]: ["Why Ctrl+Alt shouldn’t be used as a shortcut modifier"](https://devblogs.microsoft.com/oldnewthing/20040329-00/?p=40003)
Author
Owner

@PankajBhojwani commented on GitHub (Oct 18, 2023):

Thank you for reporting this!

This will require some further research into other terminal emulators to determine how they are handling the difference between AltGr and Alt + Ctrl. For now, hopefully the suggestion that j4james provided above is sufficient!

@PankajBhojwani commented on GitHub (Oct 18, 2023): Thank you for reporting this! This will require some further research into other terminal emulators to determine how they are handling the difference between AltGr and Alt + Ctrl. For now, hopefully the suggestion that j4james provided above is sufficient!
Author
Owner

@j4james commented on GitHub (Oct 19, 2023):

I've just tested a handful of terminals now, and the behavior was mostly what I expected. The Linux terminals worked correctly, i.e. Ctrl+AltGr+ß generated Ctrl+\. Most Windows terminals behaved the same as we do, i.e. both AltGr+ß and Ctrl+AltGr+ß generate \. In one case I got Alt+\ for both key combos, but that's also understandable for a Windows terminal.

The big surprise, though, was mintty, which somehow managed to get this right. That suggests it definitely must be possible to detect the Ctrl key independently of AltGr in Windows, but I have no idea how. As far as I can see, in both the conhost and WT keyboard handlers, we are receiving keydown events for both a Ctrl key and a AltGr key whenever AltGr is pressed. But maybe there is some lower level API which works better. Or maybe I'm just looking at it wrong.

@j4james commented on GitHub (Oct 19, 2023): I've just tested a handful of terminals now, and the behavior was mostly what I expected. The Linux terminals worked correctly, i.e. <kbd>Ctrl</kbd>+<kbd>AltGr</kbd>+<kbd>ß</kbd> generated <kbd>Ctrl</kbd>+<kbd>\\</kbd>. Most Windows terminals behaved the same as we do, i.e. both <kbd>AltGr</kbd>+<kbd>ß</kbd> and <kbd>Ctrl</kbd>+<kbd>AltGr</kbd>+<kbd>ß</kbd> generate <kbd>\\</kbd>. In one case I got <kbd>Alt</kbd>+<kbd>\\</kbd> for both key combos, but that's also understandable for a Windows terminal. The big surprise, though, was mintty, which somehow managed to get this right. That suggests it definitely must be possible to detect the <kbd>Ctrl</kbd> key independently of <kbd>AltGr</kbd> in Windows, but I have no idea how. As far as I can see, in both the conhost and WT keyboard handlers, we are receiving keydown events for both a <kbd>Ctrl</kbd> key and a <kbd>AltGr</kbd> key whenever <kbd>AltGr</kbd> is pressed. But maybe there is some lower level API which works better. Or maybe I'm just looking at it wrong.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20678