[PR #2836] Partially fix mapping of virtual keys to characters #25114

Open
opened 2026-01-31 09:07:21 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/2836

State: closed
Merged: Yes


Summary of the Pull Request

This PR mostly fixes the mapping of Alt combinations to unicode characters.

The case of AltGr was originally hotfixed by returning early in TerminalControl.
But this didn't fix e.g. AltShift combinations. See #2771 for instance.

This PR now fixes this particular remaining issue.
Cases where a single keypress generates more than a single UTF-16 code point (e.g. when diacritics come into play) are not fixed though, due to a limitation in the design of the low level KeyEvent class.

PR Checklist

Detailed Description of the Pull Request / Additional comments

This removes the special handling of AltGr in TerminalControl, so that terminalInput may now handle it by itself.

I believe it'd be nice to extend InputTest.cpp to include a test for the translation of Shift. to ">", but unfortunately this would be exclusive to US keyboard layouts.
My german keyboard layout for instance uses Shift< for this (there's a dedicated "<" key).
How would I build a unit test for this that works independent of "internationalization"?

Validation Steps Performed

  • Ensured that the expected behavior of #2771 can be observed.
  • The special handling of AltGr is being removed in this PR.
    -> Ensured that AltGr combinations still work.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/2836 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request This PR mostly fixes the mapping of <kbd>Alt</kbd> combinations to unicode characters. The case of <kbd>AltGr</kbd> was originally hotfixed by returning early in `TerminalControl`. But this didn't fix e.g. <kbd>Alt</kbd><kbd>Shift</kbd> combinations. See #2771 for instance. This PR now fixes this particular remaining issue. Cases where a single keypress generates more than a single UTF-16 code point (e.g. when diacritics come into play) are not fixed though, due to a limitation in the design of the low level `KeyEvent` class. ## PR Checklist * [x] Closes * Closes #2771 * Closes #1819 * Related #1694 (Not sure about that one - I don't understand the issue description) * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [x] Requires documentation to be updated * I changed the `ITerminalInput` interface * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #2771 ## Detailed Description of the Pull Request / Additional comments This removes the special handling of AltGr in `TerminalControl`, so that `terminalInput` may now handle it by itself. I believe it'd be nice to extend `InputTest.cpp` to include a test for the translation of <kbd>Shift</kbd><kbd>.</kbd> to ">", but unfortunately this would be exclusive to US keyboard layouts. My german keyboard layout for instance uses <kbd>Shift</kbd><kbd><</kbd> for this (there's a dedicated "<" key). How would I build a unit test for this that works independent of "internationalization"? ## Validation Steps Performed * Ensured that the expected behavior of #2771 can be observed. * The special handling of AltGr is being removed in this PR. -> Ensured that AltGr combinations still work.
claunia added the pull-request label 2026-01-31 09:07:21 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25114