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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/10652
Author: @carlos-zamora
Created: 7/14/2021
Status: Merged
Merged: 7/16/2021
Merged by: @undefined

Base: mainHead: dev/cazamor/actions-page/key-listener


📝 Commits (3)

  • 5c81c07 Add a KeyChordListener to the Settings UI
  • bbaf737 apply Dustin's feedback
  • dc38f9f address suggestions from Leonard

📊 Changes

12 files changed (+259 additions, -86 deletions)

View changed files

📝 src/cascadia/TerminalSettingsEditor/Actions.cpp (+14 -64)
📝 src/cascadia/TerminalSettingsEditor/Actions.h (+6 -7)
📝 src/cascadia/TerminalSettingsEditor/Actions.idl (+1 -1)
📝 src/cascadia/TerminalSettingsEditor/Actions.xaml (+8 -13)
src/cascadia/TerminalSettingsEditor/KeyChordListener.cpp (+135 -0)
src/cascadia/TerminalSettingsEditor/KeyChordListener.h (+29 -0)
src/cascadia/TerminalSettingsEditor/KeyChordListener.idl (+13 -0)
src/cascadia/TerminalSettingsEditor/KeyChordListener.xaml (+17 -0)
📝 src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj (+13 -0)
📝 src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj.filters (+5 -1)
📝 src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw (+16 -0)
📝 src/cascadia/TerminalSettingsEditor/pch.h (+2 -0)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/10652 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 7/14/2021 **Status:** ✅ Merged **Merged:** 7/16/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/cazamor/actions-page/key-listener` --- ### 📝 Commits (3) - [`5c81c07`](https://github.com/microsoft/terminal/commit/5c81c0796edc0f482e429580d26a008f3b6804b7) Add a KeyChordListener to the Settings UI - [`bbaf737`](https://github.com/microsoft/terminal/commit/bbaf737fc0e3e739abd854831c3531d8fa281ab7) apply Dustin's feedback - [`dc38f9f`](https://github.com/microsoft/terminal/commit/dc38f9f4f7f05432d8fc24e9af706d5c3208c921) address suggestions from Leonard ### 📊 Changes **12 files changed** (+259 additions, -86 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalSettingsEditor/Actions.cpp` (+14 -64) 📝 `src/cascadia/TerminalSettingsEditor/Actions.h` (+6 -7) 📝 `src/cascadia/TerminalSettingsEditor/Actions.idl` (+1 -1) 📝 `src/cascadia/TerminalSettingsEditor/Actions.xaml` (+8 -13) ➕ `src/cascadia/TerminalSettingsEditor/KeyChordListener.cpp` (+135 -0) ➕ `src/cascadia/TerminalSettingsEditor/KeyChordListener.h` (+29 -0) ➕ `src/cascadia/TerminalSettingsEditor/KeyChordListener.idl` (+13 -0) ➕ `src/cascadia/TerminalSettingsEditor/KeyChordListener.xaml` (+17 -0) 📝 `src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj` (+13 -0) 📝 `src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj.filters` (+5 -1) 📝 `src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw` (+16 -0) 📝 `src/cascadia/TerminalSettingsEditor/pch.h` (+2 -0) </details> ### 📄 Description ## 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:26:44 +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#28164