Repository navigation
fix(keyboard): keep Ctrl for the terminal on macOS, bind app shortcuts to Cmd - #844
Merged
Merged
Conversation
…s to Cmd On macOS every shortcut check treated Ctrl and Cmd as the same key, so Ctrl+C copied a selection, Ctrl+V pasted, and Ctrl+K/F/T/W/B/Z opened app actions instead of reaching the shell. One helper now names the app-shortcut modifier: Cmd on macOS, Ctrl elsewhere. Ctrl+Tab and Ctrl+Space keep Ctrl on macOS because the OS owns Cmd+Tab and Cmd+Space. Shortcut matching, the shortcut recorder, terminal copy/paste, split-pane keys, search next/previous and plugin keybindings all use it, and shortcut labels read "Cmd" on macOS. Holding the other modifier never matches an app shortcut, so Super/Win chords on Linux and Windows no longer fire Ctrl shortcuts. Fixes #843
macOS takes Cmd+Option+D to toggle the Dock, so the shortcut never reached the app. That chord keeps Ctrl, like Ctrl+Tab and Ctrl+Space. Option also rewrites e.key on macOS (Option+D is "∂"), so Option shortcuts match and record by physical key there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #843
Problem
On macOS every shortcut check accepted Ctrl or Cmd interchangeably (
e.ctrlKey || e.metaKeyinmatchShortcut, the recorder and plugin keybindings; hard-codede.ctrlKeyin terminal copy/paste). So in a terminal:Change
src/utils/primaryModifier.tsnames the app-shortcut modifier once: Cmd on macOS, Ctrl elsewhere. Ctrl+Tab and Ctrl+Space keep Ctrl on macOS because the OS owns Cmd+Tab (app switcher) and Cmd+Space (Spotlight).Routed through it:
matchShortcut(every rebindable shortcut, panel shortcuts, duplicate session)terminalClipboard): Cmd+C copies a selection, Cmd+V pastes; Ctrl+C / Ctrl+V always reach the shell on macOS. This replaces the old macOS-only Cmd+V special case.ctrlin a plugin binding means the primary modifierformatShortcutshowsCmd+Kon macOS; alias labels and the settings-manifest value now come fromformatShortcutinstead of hand-written strings; the "Ctrl+, to open" hint in Settings is interpolatedPersisted and synced shortcut data does not change:
ctrl: truekeeps meaning "primary modifier", so a binding synced from Linux reads as Cmd on a Mac.Behaviour changes to know about
|| metaKey).e.key(Option+D is "∂").Tests
shortcutStore.macModifier.test.ts: on macOS, Cmd matches and Ctrl does not, Ctrl+Tab / Ctrl+Space still match, Ctrl never fires unmodified shortcuts, labels read Cmd; elsewhere Ctrl only.terminalClipboard.test.ts: on macOS Ctrl+C / Ctrl+V with a selection returnnull(passed to xterm, so the shell gets ^C / ^V); Cmd+C copies.tsc --noEmitis clean.Not tested on a real Mac. macOS-only behaviour needs a hand check on the next build.