Skip to content

feat(shortcuts): expand keyboard shortcuts and group the Shortcuts menu - #467

Open
Dhruv-Sharma29 wants to merge 1 commit into
petertzy:mainfrom
Dhruv-Sharma29:feat/expand-keyboard-shortcuts
Open

Dhruv-Sharma29 wants to merge 1 commit into
petertzy:mainfrom
Dhruv-Sharma29:feat/expand-keyboard-shortcuts

Conversation

@Dhruv-Sharma29

Copy link
Copy Markdown
Contributor

Closes #458

Review of existing shortcuts

  • One table (DEFAULT_SHORTCUTS) already drives both the key handler and the Shortcuts menu, so no listed shortcut was missing an implementation.
  • Gaps: Open Folder, Show Preview Panel and Focus Mode had no shortcut, and Focus Mode could not be reached from any menu.
  • "Show Preview Panel" actually toggles the panel, so it is renamed Toggle Preview Panel.
  • The Shortcuts menu was one flat list of ~25 entries.

New shortcuts (all working, not just listed)

Action macOS Windows/Linux Convention
Open Folder Cmd+Shift+O Ctrl+Shift+O common "open folder" chord
Strikethrough Cmd+Shift+X Ctrl+Shift+X Slack, Notion
Inline Code Cmd+E Ctrl+E Notion, Slack
Insert Link Cmd+K Ctrl+K Word, Docs, Typora, GitHub
Toggle Focus Mode F8 F8 Typora
Toggle Preview Panel Cmd+Shift+V Ctrl+Shift+V VS Code Markdown preview
Increase / Decrease Font Size Cmd+= / Cmd+- Ctrl+= / Ctrl+- browsers, editors
Next / Previous Tab Ctrl+Tab / Ctrl+Shift+Tab Ctrl+Tab / Ctrl+Shift+Tab browsers, editors

The new commands also appear in the Format and View menus.

Single source of truth and tests

  • The table moved from keyboardShortcuts.ts into lib/shortcut-definitions.mjs. keyboardShortcuts.ts re-exports it as DEFAULT_SHORTCUTS, so existing callers are unchanged.
  • Reason for the move: CI runs on Node 20, which cannot import .ts. That is why the existing keyboard-shortcuts.test.mjs copies the logic instead of importing it. As plain JS, the real table can be tested on both platforms.
  • The Shortcuts menu is still built from that table. It now inserts a separator between categories (file, edit, format, table, view, tab).
  • New tests/shortcut-definitions.test.mjs checks, for both macOS and Windows/Linux:
    • no two commands share a key chord;
    • no command takes a reserved chord: Cmd+Q/H/M/Tab/,, the clipboard/select-all chords, or Alt+F4;
    • every command has a label and at least one binding, and both platforms expose the same commands;
    • categories are contiguous, so the menu groups cleanly.
  • docs/KeyboardShortcuts.md is updated.

Trade-offs worth a look

  • Cmd/Ctrl+K and Cmd/Ctrl+E: the app's shortcut listener runs in the capture phase, so it now takes these from Monaco. That disables Monaco's Cmd+K … chords (such as toggling a block comment) and macOS's Cmd+E "find with selection". Insert Link and Inline Code seemed more useful in a Markdown editor. Happy to pick other keys.
  • Cmd/Ctrl+Shift+V is editor-scoped. In the app's own text fields (the AI prompt, settings) it still pastes.

Testing

  • npm test (171 pass), npx tsc --noEmit, npm run lint, npm run build all pass.
  • I checked each new shortcut by hand in the dev build (macOS):
    • strikethrough, inline code and link wrap the selection;
    • F8 enters and leaves Focus Mode;
    • Cmd+Shift+V toggles the preview;
    • Cmd+= and Cmd+- change the font size;
    • Ctrl+Tab and Ctrl+Shift+Tab cycle the tabs;
    • the grouped Shortcuts menu renders.
  • I didn't test on Windows or Linux by hand. The conflict test covers those bindings.

- Add working shortcuts for Open Folder, Strikethrough, Inline Code,
  Insert Link, Toggle Focus Mode, Toggle Preview Panel, font size up and
  down, and next/previous tab.
- Add the new commands to the Format and View menus, and rename "Show
  Preview Panel" to "Toggle Preview Panel" to match what it does.
- Move the shortcut table into shortcut-definitions.mjs. The key handler
  and the Shortcuts menu still read the same table; plain JS lets the
  Node 20 test suite check the real bindings.
- Group the Shortcuts menu by category with separators.
- Test both platforms for duplicate chords, reserved system/clipboard
  chords, missing labels, and split categories.
- Update docs/KeyboardShortcuts.md.

Closes petertzy#458
Copilot AI balanced review requested due to automatic review settings November 6, 2026 08:46

Copilot AI left a comment

Copy link
Copy Markdown

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. Try requesting a review at a lower effort level.

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.

Expand Keyboard Shortcut Support and Update the Shortcuts Menu to Cover More Essential Features

2 participants