Skip to content

fix: capitalize accelerator modifiers to fix custom keybindings#4134

Open
Bowl42 wants to merge 2 commits intomarktext:developfrom
Bowl42:fix/keybinding-case
Open

fix: capitalize accelerator modifiers to fix custom keybindings#4134
Bowl42 wants to merge 2 commits intomarktext:developfrom
Bowl42:fix/keybinding-case

Conversation

@Bowl42
Copy link

@Bowl42 Bowl42 commented Mar 4, 2026

Summary

Fixes #4123

  • The keybinding preferences UI captures keyboard shortcuts via getAcceleratorFromKeyboardEvent() which returns lowercase modifier names (e.g. ctrl+alt+1), but Electron requires properly capitalized modifiers (e.g. Ctrl+Alt+1) to register shortcuts correctly.
  • Add capitalizeAccelerator() utility to src/common/keybinding/index.js that normalizes modifier casing against a canonical map (Ctrl, Alt, Shift, Cmd, Meta, Super, AltGr, Option, CommandOrControl, CmdOrCtrl, Command, Control).
  • Apply capitalization in key-input-dialog.vue immediately after capturing the accelerator, before saving.
  • Fix _isDefaultBinding in KeybindingConfigurator.js to use isEqualAccelerator (case-insensitive) instead of strict equality, so re-entering a default binding is correctly recognized.

Test plan

  • Add 21 unit tests for capitalizeAccelerator() covering all modifier names, mixed case, empty/null input, and multi-modifier combinations (test/unit/specs/capitalize-accelerator.spec.js)
  • Manual: Open Preferences > Key Bindings, edit a binding (e.g. press Ctrl+Alt+1), verify it displays as Ctrl+Alt+1 (not ctrl+alt+1)
  • Manual: Save the binding, return to document, verify the shortcut works

🤖 Generated with Claude Code

Bowl42 and others added 2 commits March 4, 2026 21:21
…text#4123)

The keybinding UI captured keyboard shortcuts with lowercase modifier
names (e.g. "ctrl+alt+1") via getAcceleratorFromKeyboardEvent(), but
Electron requires properly capitalized modifiers (e.g. "Ctrl+Alt+1").

- Add capitalizeAccelerator() utility to normalize modifier casing
- Apply capitalization in key-input-dialog before saving
- Fix _isDefaultBinding to use case-insensitive comparison
- Add comprehensive unit tests for capitalizeAccelerator

Fixes marktext#4123

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Apply capitalizeAccelerator when loading user keybindings from disk,
  healing legacy files that contain lowercase modifiers
- Fix JSDoc: clarify that only modifiers are capitalized, not key names
- Fix comment: map contains modifier names only
- Add missing test cases: single modifier without key, Plus key,
  non-modifier special keys, idempotency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Custom Key Binding fails due to lowercase "ctrl" and "alt"

1 participant