[PR #16645] Improve handling of Space key combinations #30969

Closed
opened 2026-01-31 09:44:11 +00:00 by claunia · 0 comments
Owner

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

State: closed
Merged: Yes


Summary of the Pull Request

This fixes two issues where the Space key wasn't being handled
correctly:

  • Keyboards with an AltGr+Space mapping were not generating the
    expected character.
  • Pressing a dead key followed by Space is supposed to generate the
    accent character associated with that key, but it wasn't doing so.

References and Relevant Issues

These were both regressions from the keyboard refactor in PR #16511.

Detailed Description of the Pull Request / Additional comments

The problem was that we were treating VK_SPACE as a "functional" key,
which means it gets hardcoded VT mappings which take precedence over
whatever is in the keyboard layout. This was deemed necessary to deal
with the fact that many keyboards incorrectly map Ctrl+Space as a
SP character, when it's expected to be NUL.

I've now dropped VK_SPACE from the functional mapping table and allow
it be handled by the default mapping algorithm for "graphic" keys.
However, I've also introduced a special case check for Ctrl+Space
(and other modifier variants), so we can bypass any incorrect keyboard
layouts for those combinations.

Validation Steps Performed

I couldn't test with a French-BEPO keyboard layout directly, because the
MS Keyboard Layout Creator wouldn't accept a Space key mapping that
wasn't whitespace. However, if I remapped the AltGr+Space combo to
LF, I could confirm that we are now generating that correctly.

I've also tested the dead key Space combination on various keyboard
layouts and confirmed that that is now working correctly, and checked
that the Ctrl+Space combinations are still working too.

PR Checklist

**Original Pull Request:** https://github.com/microsoft/terminal/pull/16645 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request This fixes two issues where the `Space` key wasn't being handled correctly: * Keyboards with an `AltGr`+`Space` mapping were not generating the expected character. * Pressing a dead key followed by `Space` is supposed to generate the accent character associated with that key, but it wasn't doing so. ## References and Relevant Issues These were both regressions from the keyboard refactor in PR #16511. ## Detailed Description of the Pull Request / Additional comments The problem was that we were treating `VK_SPACE` as a "functional" key, which means it gets hardcoded VT mappings which take precedence over whatever is in the keyboard layout. This was deemed necessary to deal with the fact that many keyboards incorrectly map `Ctrl`+`Space` as a `SP` character, when it's expected to be `NUL`. I've now dropped `VK_SPACE` from the functional mapping table and allow it be handled by the default mapping algorithm for "graphic" keys. However, I've also introduced a special case check for `Ctrl`+`Space` (and other modifier variants), so we can bypass any incorrect keyboard layouts for those combinations. ## Validation Steps Performed I couldn't test with a French-BEPO keyboard layout directly, because the MS Keyboard Layout Creator wouldn't accept a `Space` key mapping that wasn't whitespace. However, if I remapped the `AltGr`+`Space` combo to `LF`, I could confirm that we are now generating that correctly. I've also tested the dead key `Space` combination on various keyboard layouts and confirmed that that is now working correctly, and checked that the `Ctrl`+`Space` combinations are still working too. ## PR Checklist - [x] Closes #16641 - [x] Closes #16642
claunia added the pull-request label 2026-01-31 09:44:11 +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#30969