Windows touch keyboard - special characters not working in WSL #14080

Closed
opened 2026-01-31 04:00:20 +00:00 by claunia · 8 comments
Owner

Originally created by @leoshusar on GitHub (Jun 2, 2021).

Windows Terminal version (or Windows build number)

Microsoft Windows [10.0.19043.1023]

Other Software

No response

Steps to reproduce

  • open WSL 2
  • open touch keyboard
  • type any "AltGr char" (I tried for example @, $, , [, ], ^ on Czech keyboard or on English keyboard)

Expected Behavior

Those characters should work normally

Actual Behavior

When I write those characters, they won't appear in WSL and Windows "error" sound plays.
One difference I found is when you write # char, it writes it and sends "return" (or newline) after it.

It doesn't matter if I open WSL in Terminal, Console, or if I open PowerShell and then run wsl command. Those AltGr chars just stops working.

Originally created by @leoshusar on GitHub (Jun 2, 2021). ### Windows Terminal version (or Windows build number) Microsoft Windows [10.0.19043.1023] ### Other Software _No response_ ### Steps to reproduce - open WSL 2 - open touch keyboard - type any "AltGr char" (I tried for example `@`, `$`, `€`, `[`, `]`, `^` on Czech keyboard or `€` on English keyboard) ### Expected Behavior Those characters should work normally ### Actual Behavior When I write those characters, they won't appear in WSL and Windows "error" sound plays. One difference I found is when you write `#` char, it writes it and sends "return" (or newline) after it. It doesn't matter if I open WSL in Terminal, Console, or if I open PowerShell and then run `wsl` command. Those AltGr chars just stops working.
claunia added the Area-InputResolution-Duplicate labels 2026-01-31 04:00:20 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jul 6, 2021):

Out of curiosity, does this repro with the "On Screen Keyboard", or only the "Touch Keyboard"? Shockingly, those are two totally different codebases 😖

This sounds a lot like #10551, which I'm pretty confident is fixed in Windows 11. I'd bet that the Touch Keyboard sends garbage vkeys, or garbage scan codes, or something of the like.

@zadjii-msft commented on GitHub (Jul 6, 2021): Out of curiosity, does this repro with the "On Screen Keyboard", or _only_ the "Touch Keyboard"? Shockingly, those are two totally different codebases 😖 This sounds a lot like #10551, which I'm pretty confident is fixed in Windows 11. I'd bet that the Touch Keyboard sends garbage vkeys, or garbage scan codes, or something of the like.
Author
Owner

@leoshusar commented on GitHub (Jul 6, 2021):

Just tried it and happens with both keyboards.
Is there anything I can try? Any way to see what is being sent to WSL?

EDIT: I found showkey linux command which prints codes sent by keyboard.
I tried AltGr + @, then & and # and got this: ^@^[@^@, ^@^[&^@, ^@^[#^@
^@ is being sent on AltGr key toggle, so I guess it's AltGr press (^@), then & key press (^[&), AltGr unpress (^@).

When I send those keys from physical keyboard, only characters show up in showkey.

Screen here

@leoshusar commented on GitHub (Jul 6, 2021): Just tried it and happens with both keyboards. Is there anything I can try? Any way to see what is being sent to WSL? EDIT: I found `showkey` linux command which prints codes sent by keyboard. I tried AltGr + `@`, then `&` and `#` and got this: `^@^[@^@`, `^@^[&^@`, `^@^[#^@` `^@` is being sent on AltGr key toggle, so I guess it's AltGr press (`^@`), then `&` key press (`^[&`), AltGr unpress (`^@`). When I send those keys from physical keyboard, only characters show up in `showkey`. Screen [here](https://i.imgur.com/8BlgjRV.png)
Author
Owner

@zadjii-msft commented on GitHub (Jul 8, 2021):

The following might seem convoluted, but it might be able to help us figure out what the key getting sent to the terminal is:

  1. enable debug features by adding "debugFeatures": true, to the global settings
  2. Hold both the left and right alt keys, and open a new tab. What you should see is a tab with two panes in it, and the second one will have the "debug tap", showing all the input and output sent to the Terminal, something like:
    image
  3. repro the issue
  4. copy the output in the second pane to this issue, (and maybe share a screenshot so we can differentiate between the output and input (the red text)
@zadjii-msft commented on GitHub (Jul 8, 2021): The following might seem convoluted, but it might be able to help us figure out what the key getting sent to the terminal is: 1. enable debug features by adding `"debugFeatures": true,` to the global settings 2. Hold both the left and right <kbd>alt</kbd> keys, and open a new tab. What you should see is a tab with two panes in it, and the second one will have the "debug tap", showing all the input and output sent to the Terminal, something like: ![image](https://user-images.githubusercontent.com/18356694/99067818-f1e7d780-2570-11eb-9790-3e6cce8a96be.png) 3. repro the issue 4. copy the output in the second pane to this issue, (and maybe share a screenshot so we can differentiate between the output and input (the red text)
Author
Owner

@leoshusar commented on GitHub (Jul 8, 2021):

Ok, I tried three variants. In all three I typed @&# with AltGr release after each key.

Physical keyboard

raw data
␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[86;47;64;1;9;1_␛[86;47;64;0;9;1_@␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[67;46;38;1;9;1_␛[67;46;38;0;9;1_&␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[88;45;35;1;9;1_␛[88;45;35;0;9;1_#␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_
screen

physical

On-Screen Keyboard

raw data
␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[86;47;64;1;11;1_␛[86;47;64;0;11;1_␇␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[67;46;38;1;11;1_␛[67;46;38;0;11;1_␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[88;45;35;1;11;1_␛[88;45;35;0;11;1_#␛[32m␛[1m␍␊leoshusar@leoshusar-pc␛[m:␛[34m␛[1m/mnt/c/Users/husar␛[m$␣␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_
screen

on-screen

Touch Keyboard

raw data
␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[86;47;64;1;11;1_␛[86;47;64;0;11;1_␇␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[67;46;38;1;11;1_␛[67;46;38;0;11;1_␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[88;45;35;1;11;1_␛[88;45;35;0;11;1_#␍␊␛[32m␛[1mleoshusar@leoshusar-pc␛[m:␛[34m␛[1m/mnt/c/Users/husar␛[m$␣␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_
screen

touch

EDIT: recreated physical test for better comparison

EDIT2: I also tried PowerShell, just physical vs Touch Keyboard

Physical

raw data
␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[86;47;64;1;9;1_␛[86;47;64;0;9;1_␛[?25l␛[91m␛[7;18H>␣␛[93m@␛[?25h␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[67;46;38;1;9;1_␛[67;46;38;0;9;1_␛[m␛[?25l␛[93m␈@␛[m&␛[?25h␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[88;45;35;1;9;1_␛[88;45;35;0;9;1_␛[?25l␛[93m␛[7;20H@␛[m&␛[32m#␛[?25h␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_
screen

physical

Touch Keyboard

raw data
␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[86;47;64;1;11;1_␛[86;47;64;0;11;1_␛[?25l␛[91m␛[7;18H>␣␛[93m@␛[?25h␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[67;46;38;1;11;1_␛[67;46;38;0;11;1_␛[m␛[?25l␛[93m␈@␛[m&␛[?25h␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[88;45;35;1;11;1_␛[88;45;35;0;11;1_␛[?25l␛[93m␛[7;20H@␛[m&␛[32m#␛[?25h␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_
screen

touch

@leoshusar commented on GitHub (Jul 8, 2021): Ok, I tried three variants. In all three I typed @&# with AltGr release after each key. **Physical keyboard** <details> <summary>raw data</summary> ``` ␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[86;47;64;1;9;1_␛[86;47;64;0;9;1_@␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[67;46;38;1;9;1_␛[67;46;38;0;9;1_&␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[88;45;35;1;9;1_␛[88;45;35;0;9;1_#␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_ ``` </details> <details> <summary>screen</summary> ![physical](https://i.imgur.com/uOQXtaF.png) </details> **On-Screen Keyboard** <details> <summary>raw data</summary> ``` ␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[86;47;64;1;11;1_␛[86;47;64;0;11;1_␇␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[67;46;38;1;11;1_␛[67;46;38;0;11;1_␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[88;45;35;1;11;1_␛[88;45;35;0;11;1_#␛[32m␛[1m␍␊leoshusar@leoshusar-pc␛[m:␛[34m␛[1m/mnt/c/Users/husar␛[m$␣␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_ ``` </details> <details> <summary>screen</summary> ![on-screen](https://i.imgur.com/h6H0wJ6.png) </details> **Touch Keyboard** <details> <summary>raw data</summary> ``` ␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[86;47;64;1;11;1_␛[86;47;64;0;11;1_␇␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[67;46;38;1;11;1_␛[67;46;38;0;11;1_␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[88;45;35;1;11;1_␛[88;45;35;0;11;1_#␍␊␛[32m␛[1mleoshusar@leoshusar-pc␛[m:␛[34m␛[1m/mnt/c/Users/husar␛[m$␣␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_ ``` </details> <details> <summary>screen</summary> ![touch](https://i.imgur.com/w8bPryl.png) </details> EDIT: recreated physical test for better comparison EDIT2: I also tried PowerShell, just physical vs Touch Keyboard **Physical** <details> <summary>raw data</summary> ``` ␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[86;47;64;1;9;1_␛[86;47;64;0;9;1_␛[?25l␛[91m␛[7;18H>␣␛[93m@␛[?25h␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[67;46;38;1;9;1_␛[67;46;38;0;9;1_␛[m␛[?25l␛[93m␈@␛[m&␛[?25h␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_␛[17;29;0;1;8;1_␛[18;56;0;1;265;1_␛[88;45;35;1;9;1_␛[88;45;35;0;9;1_␛[?25l␛[93m␛[7;20H@␛[m&␛[32m#␛[?25h␛[17;29;0;0;1;1_␛[18;56;0;0;0;1_ ``` </details> <details> <summary>screen</summary> ![physical](https://i.imgur.com/zPFNQaa.png) </details> **Touch Keyboard** <details> <summary>raw data</summary> ``` ␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[86;47;64;1;11;1_␛[86;47;64;0;11;1_␛[?25l␛[91m␛[7;18H>␣␛[93m@␛[?25h␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[67;46;38;1;11;1_␛[67;46;38;0;11;1_␛[m␛[?25l␛[93m␈@␛[m&␛[?25h␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_␛[17;29;0;1;8;1_␛[18;56;0;1;10;1_␛[88;45;35;1;11;1_␛[88;45;35;0;11;1_␛[?25l␛[93m␛[7;20H@␛[m&␛[32m#␛[?25h␛[17;29;0;0;3;1_␛[18;56;0;0;1;1_ ``` </details> <details> <summary>screen</summary> ![touch](https://i.imgur.com/YV3kJEI.png) </details>
Author
Owner

@leoshusar commented on GitHub (Oct 15, 2021):

So, just came to say that after upgrade to Win11 it indeed works fine.

@leoshusar commented on GitHub (Oct 15, 2021): So, just came to say that after upgrade to Win11 it indeed works fine.
Author
Owner

@zadjii-msft commented on GitHub (Oct 15, 2021):

Well that's good to hear! Let's just call this /dup #10551 until we're proven otherwise then. Thanks!

@zadjii-msft commented on GitHub (Oct 15, 2021): Well that's good to hear! Let's just call this /dup #10551 until we're proven otherwise then. Thanks!
Author
Owner

@ghost commented on GitHub (Oct 15, 2021):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Oct 15, 2021): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@j4james commented on GitHub (Dec 30, 2023):

FYI, the reason this doesn't work is because the Touch and On-Screen keyboards generate too many Alt modifiers in the control key state. On a physical keyboard, when you press AltGr, it actually generates two keypresses - a LeftCtrl and a RightAlt. This is because there isn't actually an AltGr mapping in Windows keyboard layouts - it's really just a Ctrl+Alt mapping, so the AltGr key needs to emulate that state.

However, when you press AltGr on a touch keyboard, it generates a LeftCtrl and a LeftAlt. That would be fine, except when the character key is pressed, it also sets an additional RightAlt modifier for no apparent reason. So we'll see the key as something like Ctrl+LAlt+RAlt+4, which is interpreted as Alt+AltGr+4, and thus you get an unexpected ESC prefix on your character.

I've got a fix for this is in my keyboard refactor for #16506 (PR #16511), which I think should still be harmless on versions of Windows that don't have the bug. The way it works is I keep a record of the last control key state, and if I receive a key press with a new RightAlt modifier set, when it wasn't a RightAlt key that was pressed, I simply discard that modifier. It's a bit of a hack, but it works.

@j4james commented on GitHub (Dec 30, 2023): FYI, the reason this doesn't work is because the Touch and On-Screen keyboards generate too many <kbd>Alt</kbd> modifiers in the control key state. On a physical keyboard, when you press <kbd>AltGr</kbd>, it actually generates two keypresses - a <kbd>LeftCtrl</kbd> and a <kbd>RightAlt</kbd>. This is because there isn't actually an <kbd>AltGr</kbd> mapping in Windows keyboard layouts - it's really just a <kbd>Ctrl</kbd>+<kbd>Alt</kbd> mapping, so the <kbd>AltGr</kbd> key needs to emulate that state. However, when you press <kbd>AltGr</kbd> on a touch keyboard, it generates a <kbd>LeftCtrl</kbd> and a <kbd>LeftAlt</kbd>. That would be fine, except when the character key is pressed, it also sets an additional <kbd>RightAlt</kbd> modifier for no apparent reason. So we'll see the key as something like <kbd>Ctrl</kbd>+<kbd>LAlt</kbd>+<kbd>RAlt</kbd>+<kbd>4</kbd>, which is interpreted as <kbd>Alt</kbd>+<kbd>AltGr</kbd>+<kbd>4</kbd>, and thus you get an unexpected `ESC` prefix on your `€` character. I've got a fix for this is in my keyboard refactor for #16506 (PR #16511), which I think should still be harmless on versions of Windows that don't have the bug. The way it works is I keep a record of the last control key state, and if I receive a key press with a new <kbd>RightAlt</kbd> modifier set, when it wasn't a <kbd>RightAlt</kbd> key that was pressed, I simply discard that modifier. It's a bit of a hack, but it works.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14080