Repository navigation
fix(shortcuts): accept bare Return as a macOS shortcut key - #183
Conversation
MAC_KEYCODES.ENTER was 52, but the Return key on a Mac keyboard sends kVK_Return, which is 36. utils/keycode-map.ts already names 36 "Enter" and calls it the canonical code, keeping 52 as a legacy alias, and the Swift helper's enterKeyCodes in ShortcutManager.swift is [36, 52, 76]. Only utils/shortcut-constants.ts was left behind: MAC_SPECIAL_KEYCODES listed 52 alone, so keycode 36 never reached the special-key branch of checkAlphanumericOnly in utils/shortcut-validation.ts. The effect is that recording Return on its own in the shortcut editor fails with "add a modifier", while bare Space, Tab, Escape and the function keys are all accepted, and Windows accepts its own bare Enter because WINDOWS_SPECIAL_KEYCODES holds VK_RETURN. Keypad Enter, 76, was missing for the same reason, so on Windows numpad Enter was accepted (VK_RETURN covers both keys) and on macOS it was not. MAC_KEYCODES.ENTER is now 36 with ENTER_LEGACY 52 and KEYPAD_ENTER 76 beside it, and MAC_SPECIAL_KEYCODES lists all three. Nothing else reads MAC_KEYCODES.ENTER: MAC_SPECIAL_KEYCODES was its only consumer, and the reserved-shortcut tables never used it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe shortcut utilities now distinguish standard, legacy, and keypad Enter keycodes on macOS. Special-key classification includes all variants, with tests covering macOS and Windows Enter handling. ChangesEnter keycode handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to macOS Return, legacy Enter, and Keypad Enter can now be used without modifiers in shortcut bindings while preserving Windows Enter behavior. The updated validation coverage supports merge readiness. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
On macOS the Return key sends
kVK_Return, which is keycode 36, butMAC_KEYCODES.ENTERinapps/desktop/src/utils/keycodes.tswas 52. So recording Return on its own in the shortcut editor is rejected with "add a modifier", even though bare Space, Tab, Escape and the function keys are all accepted, and Windows accepts its own bare Enter.Root cause
apps/desktop/src/utils/keycode-map.tsalready knows the right answer. Line 52 maps36: "Enter"and calls it the canonicalkVK_Return, keeping52: "Enter"below it as a legacy alias, andShortcutManager.swiftline 40 declaresenterKeyCodes: Set<Int> = [36, 52, 76]. So keycode 36 travels all the way throughisKnownKeycodeandaddActiveKeyinapps/desktop/src/main/managers/shortcut-manager.tsand reaches validation as a normal chord.apps/desktop/src/utils/shortcut-constants.tswas the one place left behind.MAC_SPECIAL_KEYCODESon line 87 listedMAC_KEYCODES.ENTER, which was only 52, so keycode 36 never matched thehasSpecialKeybranch ofcheckAlphanumericOnlyinapps/desktop/src/utils/shortcut-validation.tsline 169 and fell through to theaddModifiererror.Keypad Enter, keycode 76, was missing for the same reason.
keycode-map.tsnames itKeypadEnterandshortcut-manager.tsline 610 treatsEnterandKeypadEnteralike, and on WindowsVK_RETURNcovers both the main and numpad keys soWINDOWS_SPECIAL_KEYCODESalready accepted numpad Enter. macOS did not.Fix
MAC_KEYCODES.ENTERis now 36, withENTER_LEGACY52 andKEYPAD_ENTER76 beside it, andMAC_SPECIAL_KEYCODESlists all three.MAC_SPECIAL_KEYCODESwas the only consumer ofMAC_KEYCODES.ENTER, and the reserved-shortcut tables never referenced it, so changing its value affects nothing else.Verification
pnpm --filter @amical/desktop teston macOS 26.2 arm64 with Node 24.8.0 and pnpm 10.15.0 gives 119 of 120 files and 1112 of 1113 tests passing. The one failure,tests/vite/posthog-source-maps.test.ts > uses a stable app release and deletes uploaded maps from the bundle, fails identically onmainat 14a62ea with nothing of mine applied, so it is not from this change.The three new assertions in
apps/desktop/tests/utils/shortcut-validation.test.tsfail onmainand pass with this change. Checking out just the two source files frommainand rerunning that file gives3 failed | 11 passed, with each failure reportingsettings.shortcuts.validation.addModifier. The two control cases in the same block, the legacy alias 52 on macOS andVK_RETURNon Windows, pass both before and after, which is what pins this to the missing keycodes rather than to the check itself.pnpm --filter @amical/desktop type:checkreports no errors,prettier --checkreports no changes for the three files, andeslinton the two changed source files is clean.Summary by CodeRabbit
Bug Fixes
Tests