[PR #7686] Fix #5784: Key bindings won't consume dead keys #26971

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

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

State: closed
Merged: Yes


Summary of the Pull Request

Let's assume the user has bound the dead key ^ to a sendInput command that sends "b".
If the user presses the two keys ^a it'll produce "bâ", despite us marking the key event as handled.
We can use ToUnicodeEx to clear such dead keys from the keyboard state and should make use of that for keybindings.
Unfortunately SetKeyboardState cannot be used for this purpose as it doesn't clear the dead key state.

PR Checklist

  • Closes copy/paste issue over SSH connection (#5784)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema 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: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

  • Enabled a German keyboard layout
  • Added the following two keybindings:
    { "command": { "action": "sendInput", "input": "x" }, "keys": "q" },
    { "command": { "action": "sendInput", "input": "b" }, "keys": "^" }
    
  • Pressed the following keys → and ensured that the given text is printed in that order:
    • q → x
    • ´ → nothing
    • a → á
    • ^ → b
    • a → a (previously this would print: â)
    • ´ → nothing
    • ^ → b
    • a → a (unfortunately we cannot specifically clear only ^)
**Original Pull Request:** https://github.com/microsoft/terminal/pull/7686 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Let's assume the user has bound the dead key <kbd>^</kbd> to a sendInput command that sends "b". If the user presses the two keys <kbd>^</kbd><kbd>a</kbd> it'll produce "bâ", despite us marking the key event as handled. We can use `ToUnicodeEx` to clear such dead keys from the keyboard state and should make use of that for keybindings. Unfortunately `SetKeyboardState` cannot be used for this purpose as it doesn't clear the dead key state. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #5784 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema 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: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed * Enabled a German keyboard layout * Added the following two keybindings: ```json { "command": { "action": "sendInput", "input": "x" }, "keys": "q" }, { "command": { "action": "sendInput", "input": "b" }, "keys": "^" } ``` * Pressed the following keys → and ensured that the given text is printed in that order: * <kbd>q</kbd> → x * <kbd>´</kbd> → nothing * <kbd>a</kbd> → á * <kbd>^</kbd> → b * <kbd>a</kbd> → a (previously this would print: â) * <kbd>´</kbd> → nothing * <kbd>^</kbd> → b * <kbd>a</kbd> → a (unfortunately we cannot specifically clear only ^)
claunia added the pull-request label 2026-01-31 09:19:12 +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#26971