[PR #15753] ConHost: Ignore WM_[SYS]KEYDOWN/WM_[SYS]KEYUP events with an invalid virtual keycode and a scan code of 0 #30721

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

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

State: closed
Merged: Yes


Summary

Applications like PowerToys, with their keyboard remapping features frequently (i.e whenever a remapped shortcut is triggerred) send KeyEvent with out-of-range virtual keycode values (E.g. 0xFF). This is fixed for WT in #7145, we just needed it in our good ol' conhost.

After this PR, Key events with an invalid virtual keycode and scancode==0 are ignored, and are not added to the InputBuffer. Incase, only virtual keycode is valid but not scancode, we will try to infer the correct scancode using the virtual keycode mapping.

References and Relevant Issues

#7145
#7064

Validation Steps Performed

  • Triggered a remapped shortcut and verified that showkey -a doesn't output ^@ unexpectedly.
  • Key events with an Invalid virtual Keycode and Scancode == 0 are ignored.
  • This PR doesn't include any changes for WM_[SYS][DEAD]CHAR messages, they are left unchanged.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/15753 **State:** closed **Merged:** Yes --- ## Summary Applications like PowerToys, with their keyboard remapping features frequently (i.e whenever a remapped shortcut is triggerred) send `KeyEvent` with out-of-range virtual keycode values (E.g. 0xFF). This is fixed for WT in #7145, we just needed it in our good ol' `conhost`. After this PR, Key events with an invalid virtual keycode and scancode==0 are ignored, and are not added to the `InputBuffer`. Incase, only virtual keycode is valid but not scancode, we will try to infer the correct scancode using the virtual keycode mapping. ## References and Relevant Issues #7145 #7064 ## Validation Steps Performed - Triggered a remapped shortcut and verified that `showkey -a` doesn't output `^@` unexpectedly. - Key events with an Invalid virtual Keycode and Scancode == 0 are ignored. - This PR doesn't include any changes for `WM_[SYS][DEAD]CHAR` messages, they are left unchanged.
claunia added the pull-request label 2026-01-31 09:42:35 +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#30721