Skip to content

fix: Ignore duplicate modifier key releases in keyboard chords - #344157

Open
Zhao Chi (vectorsss) wants to merge 1 commit into
microsoft:mainfrom
vectorsss:fix/universal-control-modifier-keyup
Open

Zhao Chi (vectorsss) wants to merge 1 commit into
microsoft:mainfrom
vectorsss:fix/universal-control-modifier-keyup

Conversation

@vectorsss

Copy link
Copy Markdown

Fixes #344156

When using Apple Universal Control, VS Code can receive repeated modifier keyup events without an intervening corresponding keydown. Single-modifier chord handling interprets these as a double tap and cancels the pending chord. For example, Cmd+K, release all keys, then V can report (⌘K, ⌘) is not a command before V is pressed.

This change tracks released modifiers in AbstractKeybindingService and ignores subsequent releases of the same modifier until its next keydown. It uses code when available to distinguish left and right modifiers, with a fallback to the normalized keyCode. A new keydown allows the next release to be processed, preserving intentional modifier double taps.

Validation

  • Common keybinding suites: 72 passing, including 11 added regression cases covering all four modifiers, pending chords, intentional double taps, left/right identities, Shift/Cmd release ordering, and composition events. Tests were run through targeted transpilation and the existing Node unit test runner.
  • Targeted TypeScript check and git diff --check: passed.
  • Physical Universal Control test: backported this change to an isolated VS Code 1.143.1 test app and tested a NiZ keyboard shared from a Mac mini to a MacBook. Both Cmd+K V and Shift+Cmd+K V opened the Markdown preview to the side. Troubleshooting logs confirmed duplicate Meta/Shift releases were ignored and markdown.showPreviewToSide was invoked.

A full product build and full integration test run have not been performed.

Manual verification

  1. Use Universal Control to share a keyboard from one Mac to another.
  2. On the receiving Mac, open a Markdown file and configure the preview keybindings from Universal Control: duplicate modifier keyup events cancel keyboard chords on macOS #344156.
  3. Press Cmd+K, release all keys, then press V. Repeat with Shift+Cmd+K, release all keys, then V.
  4. Verify that both shortcuts open the side preview without a modifier-only invalid-chord message. Repeat using the receiving Mac's built-in keyboard.

Copilot AI balanced review requested due to automatic review settings October 25, 2026 19:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@vectorsss

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@vectorsss
Zhao Chi (vectorsss) force-pushed the fix/universal-control-modifier-keyup branch from c6e908c to c1e5349 Compare October 25, 2026 21:03
@vectorsss
Zhao Chi (vectorsss) force-pushed the fix/universal-control-modifier-keyup branch 2 times, most recently from 38b2d81 to d7be16d Compare October 26, 2026 08:33
@vectorsss Zhao Chi (vectorsss) changed the title Ignore duplicate modifier key releases in keyboard chords fix: Ignore duplicate modifier key releases in keyboard chords Oct 26, 2026
@vectorsss
Zhao Chi (vectorsss) force-pushed the fix/universal-control-modifier-keyup branch 7 times, most recently from 436fafa to 6116440 Compare October 27, 2026 11:35
@vectorsss
Zhao Chi (vectorsss) requested a balanced review from Copilot October 27, 2026 11:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@vectorsss
Zhao Chi (vectorsss) force-pushed the fix/universal-control-modifier-keyup branch 2 times, most recently from 7d31f2a to 412707c Compare October 27, 2026 19:14
@vectorsss
Zhao Chi (vectorsss) force-pushed the fix/universal-control-modifier-keyup branch 2 times, most recently from d0a95d0 to 14624ff Compare October 29, 2026 19:01
@vectorsss

Copy link
Copy Markdown
Author

Ulugbek Abdullaev (@ulugbekna), could you take a look at the proposed approach when you have a chance? The change addresses duplicate modifier keyup events observed with Universal Control and includes regression tests. A backport to VS Code 1.143.1 resolved the issue in my two-Mac setup. I can provide additional keyboard event traces or reproduction details if helpful. Thanks!

@vectorsss
Zhao Chi (vectorsss) force-pushed the fix/universal-control-modifier-keyup branch 3 times, most recently from c955848 to 8fa1163 Compare October 30, 2026 10:19
@vectorsss
Zhao Chi (vectorsss) requested a lite review from Copilot October 31, 2026 15:59
@vectorsss
Zhao Chi (vectorsss) force-pushed the fix/universal-control-modifier-keyup branch from 8fa1163 to 20b09bf Compare October 31, 2026 15:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The reviewed implementation has no additional findings, and the only noted item is a non-blocking test-coverage nit.

No open issues 🎉

Review effort: Lite

@vectorsss
Zhao Chi (vectorsss) force-pushed the fix/universal-control-modifier-keyup branch 9 times, most recently from aff1414 to 4d440e7 Compare November 6, 2026 16:48
@vectorsss
Zhao Chi (vectorsss) force-pushed the fix/universal-control-modifier-keyup branch 4 times, most recently from 818677c to 04b179d Compare November 12, 2026 07:25
@vectorsss
Zhao Chi (vectorsss) force-pushed the fix/universal-control-modifier-keyup branch 2 times, most recently from 6bd22f0 to cb8792a Compare November 20, 2026 16:37
@vectorsss
Zhao Chi (vectorsss) force-pushed the fix/universal-control-modifier-keyup branch from cb8792a to dc6853a Compare November 30, 2026 17:26

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Universal Control: duplicate modifier keyup events cancel keyboard chords on macOS

3 participants