[PR #10652] Add a KeyChordListener to the Settings UI #28169

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

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

State: closed
Merged: Yes


Summary of the Pull Request

Replaces the key chord editor in the actions page with a listener instead of a plain text box.

References

#6900 - Settings UI Epic

Detailed Description of the Pull Request / Additional comments

  • Actions page:
    • Replace Keys with CurrentKeys for consistency with Action/CurrentAction
    • ProposedKeys is now a Control::KeyChord
    • removes key chord validation (now we don't need it)
    • removes accept/cancel shortcuts (nowhere we could use it now)
  • KeyChordListener:
    • Keys: dependency property that hooks us up to a system to the committed setting value
      • this is the key binding view model, which propagates the change to the settings model clone on "accept changes"
    • We bind to PreviewKeyDown to intercept the key event before some special key bindings are handled (i.e. "select all" in the text box)
    • CoreWindow is used to get the modifier keys because (1) it's easier than updating on each key press and (2) that approach resulted in a strange bug where the Alt key-up event was not detected
    • LosingFocus means that we have completed our operation and want to commit our changes to the key binding view model
    • KeyDown does most of the magic of updating Keys. We filter out any key chords that could be problematic (i.e. Shift+Tab and Tab for keyboard navigation)

Validation Steps Performed

  • Tested a few key chords:
    • single key: X
    • key with modifier(s): Ctrl+Alt+X
    • plain modifier: Ctrl
    • key that is used by text box: Ctrl+A
    • key that is used by Windows Terminal: Alt+F4
    • key that is taken by Windows OS: Windows+X
    • key that is not taken by Windows OS: Windows+Shift+X
  • Known issue:
    • global key taken by Windows Terminal: (i.e. quake mode keybinding)
      • Behavior: global key binding executed
      • Expected: key chord recorded

Demo

Key Chord Listener Demo

**Original Pull Request:** https://github.com/microsoft/terminal/pull/10652 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Replaces the key chord editor in the actions page with a listener instead of a plain text box. ## References #6900 - Settings UI Epic ## Detailed Description of the Pull Request / Additional comments - `Actions` page: - Replace `Keys` with `CurrentKeys` for consistency with `Action`/`CurrentAction` - `ProposedKeys` is now a `Control::KeyChord` - removes key chord validation (now we don't need it) - removes accept/cancel shortcuts (nowhere we could use it now) - `KeyChordListener`: - `Keys`: dependency property that hooks us up to a system to the committed setting value - this is the key binding view model, which propagates the change to the settings model clone on "accept changes" - We bind to `PreviewKeyDown` to intercept the key event _before_ some special key bindings are handled (i.e. "select all" in the text box) - `CoreWindow` is used to get the modifier keys because (1) it's easier than updating on each key press and (2) that approach resulted in a strange bug where the <kbd>Alt</kbd> key-up event was not detected - `LosingFocus` means that we have completed our operation and want to commit our changes to the key binding view model - `KeyDown` does most of the magic of updating `Keys`. We filter out any key chords that could be problematic (i.e. <kbd>Shift</kbd>+<kbd>Tab</kbd> and <kbd>Tab</kbd> for keyboard navigation) ## Validation Steps Performed - Tested a few key chords: - ✅single key: <kbd>X</kbd> - ✅key with modifier(s): <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>X</kbd> - ❌plain modifier: <kbd>Ctrl</kbd> - ✅key that is used by text box: <kbd>Ctrl+A</kbd> - ✅key that is used by Windows Terminal: <kbd>Alt</kbd>+<kbd>F4</kbd> - ❌key that is taken by Windows OS: <kbd>Windows</kbd>+<kbd>X</kbd> - ✅key that is not taken by Windows OS: <kbd>Windows</kbd>+<kbd>Shift</kbd>+<kbd>X</kbd> - Known issue: - global key taken by Windows Terminal: (i.e. quake mode keybinding) - Behavior: global key binding executed - Expected: key chord recorded ## Demo ![Key Chord Listener Demo](https://user-images.githubusercontent.com/11050425/125538094-08ea4eaa-21eb-4488-a74c-6ce65324cdf1.gif)
claunia added the pull-request label 2026-01-31 09:26: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#28169