[PR #5272] Fixed #5205: Ctrl+Alt+2 doesn't send ^[^@ #26222

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

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

State: closed
Merged: Yes


Summary of the Pull Request

Fixes #5205, by replacing another use of MapVirtualKeyW with ToUnicodeEx.
The latter just seems to be much more consistent at translating key combinations in general.
In this particular case though it fixes the issue, because there's no differentiation in MapVirtualKeyW for whether it failed to return a character ('\0') or succeeded in turning ^@ into '\0'.
ToUnicodeEx on the other hand returns the success state separately from the translated character.

PR Checklist

  • Closes Support resetting the colors via OSC 104, 110, 111... (#5205)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • 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: #5205

Detailed Description of the Pull Request / Additional comments

This PR changes the behavior of the Ctrl+Alt+Key handling slightly:
⚠️ ToUnicodeEx returns unshifted characters. ⚠️
For instance Ctrl+Alt+a is now turned into ^[^a. Due to how ASCII works this is essentially the same though because 'A' & 0b11111 and 'a' & 0b11111 are the same.

Validation Steps Performed

  • Run showkey -a
  • Ensured Ctrl+Alt+Space as well as Ctrl+Alt+Shift+2 are turned into ^[^@
  • Ensured other, random Ctrl+Alt+Key combination behave identical to the current master
**Original Pull Request:** https://github.com/microsoft/terminal/pull/5272 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Fixes #5205, by replacing another use of `MapVirtualKeyW` with `ToUnicodeEx`. The latter just seems to be much more consistent at translating key combinations in general. In this particular case though it fixes the issue, because there's no differentiation in `MapVirtualKeyW` for whether it failed to return a character (`'\0'`) or succeeded in turning `^@` into `'\0'`. `ToUnicodeEx` on the other hand returns the success state separately from the translated character. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #5205 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [ ] Requires documentation to be updated * [x] 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: #5205 ## Detailed Description of the Pull Request / Additional comments This PR changes the behavior of the `Ctrl+Alt+Key` handling slightly: ⚠️ `ToUnicodeEx` returns unshifted characters. ⚠️ For instance `Ctrl+Alt+a` is now turned into `^[^a`. Due to how ASCII works this is essentially the same though because `'A' & 0b11111` and `'a' & 0b11111` are the same. ## Validation Steps Performed * Run `showkey -a` * Ensured `Ctrl+Alt+Space` as well as `Ctrl+Alt+Shift+2` are turned into `^[^@` * Ensured other, random `Ctrl+Alt+Key` combination behave identical to the current master
claunia added the pull-request label 2026-01-31 09:14:45 +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#26222