Alt+<Unicode Char> should emit Alt+<Underlying ASCII Char> #23285

Closed
opened 2026-01-31 08:37:42 +00:00 by claunia · 7 comments
Owner

Originally created by @lhecker on GitHub (May 23, 2025).

Steps to reproduce

  • Install a Russian, Hebrew, etc., keyboard layout
  • Launch showkey -a in WSL
  • Press Alt+F

Expected Behavior

Results in ESC f.

Actual Behavior

Results in ESC <some Unicode character>.

I believe this behavior is technically correct, but unexpected from the POV of terminal application authors. Their key bindings are likely for ESC <ASCII> instead.

Related: https://github.com/microsoft/edit/issues/50
Likely related? #17197

Originally created by @lhecker on GitHub (May 23, 2025). ### Steps to reproduce * Install a Russian, Hebrew, etc., keyboard layout * Launch `showkey -a` in WSL * Press Alt+F ### Expected Behavior Results in `ESC f`. ### Actual Behavior Results in `ESC <some Unicode character>`. I believe this behavior is technically correct, but unexpected from the POV of terminal application authors. Their key bindings are likely for `ESC <ASCII>` instead. Related: https://github.com/microsoft/edit/issues/50 Likely related? #17197
Author
Owner

@j4james commented on GitHub (May 25, 2025):

Just for the record, this behavior was by design, because that was the way XTerm, Gnome Terminal, Konsole, and Mintty all worked (in the case of Xterm, this is assuming the alt-sends-esc mode is enabled). I don't necessarily think it's a good design, but I'm not sure that changing the behavior in Windows Terminal is really a solution to the problem.

For an app dev, I would think a more practical solution would be to use one of the other keyboard protocols. If you just want something that works in Windows Terminal you could always use the win32 input mode. And for broader support I'm assuming the kitty keyboard protocol or xtmodkeys should be able to provide equivalent functionality.

@j4james commented on GitHub (May 25, 2025): Just for the record, this behavior was by design, because that was the way XTerm, Gnome Terminal, Konsole, and Mintty all worked (in the case of Xterm, this is assuming the alt-sends-esc mode is enabled). I don't necessarily think it's a good design, but I'm not sure that changing the behavior in Windows Terminal is really a solution to the problem. For an app dev, I would think a more practical solution would be to use one of the other keyboard protocols. If you just want something that works in Windows Terminal you could always use the win32 input mode. And for broader support I'm assuming the kitty keyboard protocol or xtmodkeys should be able to provide equivalent functionality.
Author
Owner

@j4james commented on GitHub (May 25, 2025):

And note that #17197 is unrelated. That's a PSReadLine bug, and they're not using VT sequences. They attempt to interpret the Ctrl keys themselves from a ConsoleKeyInfo report.

@j4james commented on GitHub (May 25, 2025): And note that #17197 is unrelated. That's a PSReadLine bug, and they're not using VT sequences. They attempt to interpret the Ctrl keys themselves from a `ConsoleKeyInfo` report.
Author
Owner

@lhecker commented on GitHub (May 25, 2025):

Good point, I didn't even try to test this in NIX terminals, I just assumed that we may be doing something wrong. I'm surprised to hear that other terminals send a Unicode character for such combinations, although I can understand why.

The win32 input mode protocol is not necessarily something I'd want to use at its design is very specific to Windows IMO. Maybe I'll implement the kitty keyboard protocol in Edit for now and then try to implement it in WT as soon as I can?

@lhecker commented on GitHub (May 25, 2025): Good point, I didn't even try to test this in NIX terminals, I just assumed that we may be doing something wrong. I'm surprised to hear that other terminals send a Unicode character for such combinations, although I can understand why. The win32 input mode protocol is not necessarily something I'd want to use at its design is very specific to Windows IMO. Maybe I'll implement the kitty keyboard protocol in Edit for now and then try to implement it in WT as soon as I can?
Author
Owner

@lhecker commented on GitHub (May 25, 2025):

I do have to say though that I consider the win32im protocol to be better than the kitty one, if I'm entirely honest, because it seems a lot simpler. I always have a bit of a hard time reading the kitty spec because it seems rather complex and I'm not sure why. 😅 Although I wish the field order for win32im was different and that it wouldn't use CSI _, I would not be sad if the NIX world adopted it... 😅

@lhecker commented on GitHub (May 25, 2025): I do have to say though that I consider the win32im protocol to be better than the kitty one, if I'm entirely honest, because it seems a lot simpler. I always have a bit of a hard time reading the kitty spec because it seems rather complex and I'm not sure why. 😅 Although I wish the field order for win32im was different and that it wouldn't use `CSI _`, I would not be sad if the NIX world adopted it... 😅
Author
Owner

@j4james commented on GitHub (May 25, 2025):

I've always felt that kitty tends to overcomplicate things, but in the case of the keyboard protocol the complication is somewhat justified. I think the goal was to remain largely backwards compatible by default, with progressive enhancement providing additional functionality as needed. So apps don't have to buy in to a whole new protocol to get started. They can just start with a basic enhancement that disambiguates keys that don't have unique sequences. Then the option is still there for more advanced functionality (like separate press and release events), if that's something they need.

@j4james commented on GitHub (May 25, 2025): I've always felt that kitty tends to overcomplicate things, but in the case of the keyboard protocol the complication is somewhat justified. I think the goal was to remain largely backwards compatible by default, with progressive enhancement providing additional functionality as needed. So apps don't have to buy in to a whole new protocol to get started. They can just start with a basic enhancement that disambiguates keys that don't have unique sequences. Then the option is still there for more advanced functionality (like separate press and release events), if that's something they need.
Author
Owner

@DHowett commented on GitHub (May 28, 2025):

Thanks for the history, @j4james. Leonard suggested we close this as a /duplicate of #11509.

@DHowett commented on GitHub (May 28, 2025): Thanks for the history, @j4james. Leonard suggested we close this as a /duplicate of #11509.
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (May 28, 2025):

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!

@microsoft-github-policy-service[bot] commented on GitHub (May 28, 2025): 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! <!-- Policy app identification https://img.shields.io/static/v1?label=PullRequestIssueManagement. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23285