[01088] Fix Button keyboard shortcuts on Mac with Alt/CMD modifiers#2962
Merged
[01088] Fix Button keyboard shortcuts on Mac with Alt/CMD modifiers#2962
Conversation
…event.key On Mac, Alt/Option key produces special characters (e.g. Alt+K → ˚) causing event.key comparison to fail. Using event.code compares the physical key regardless of modifiers or keyboard layout. - Add keyToCode() utility in shortcut.ts to map key names to KeyboardEvent.code values - Update ButtonWidget.tsx to use event.code for shortcut matching - Update useShortcutKey.ts with the same fix for input widget shortcuts
- Add Alt+C (Copy) and Cmd+V (Paste) buttons to ButtonApp keyboard shortcuts section - Add Playwright tests for Alt+letter, Ctrl+letter, special key, and Ctrl+Enter shortcuts - Add test for shortcut key label display on buttons
Collaborator
Deploy timed outI'm preparing your docs & samples for this PR. I'll update the comment as Sliplane reports progress. Logs |
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.
Summary
Fixed keyboard shortcuts on Mac when using Alt (Option) or CMD modifiers. The root cause was that
event.keyreturns special characters on Mac when Alt is held (e.g., Alt+K produces "˚"), so key comparisons failed. Replacedevent.keywithevent.codewhich represents the physical key regardless of modifiers. Also fixed the same bug in theuseShortcutKeyhook used by input widgets.API Changes
keyToCode(key: string): stringexport toshortcut.ts— maps key names (e.g., "k", "Enter", "Delete") toKeyboardEvent.codevalues (e.g., "KeyK", "Enter", "Delete").Files Modified
Frontend (core fix):
src/frontend/src/widgets/inputs/TextInputWidget/utils/shortcut.ts— AddedkeyToCodeutility functionsrc/frontend/src/widgets/button/ButtonWidget.tsx— Replacedevent.keycomparison withevent.codesrc/frontend/src/widgets/inputs/TextInputWidget/hooks/useShortcutKey.ts— Same fix for input shortcut handlingSamples:
src/Ivy.Samples.Shared/Apps/Widgets/ButtonApp.cs— Added Alt+C and Cmd+V shortcut buttonsTests:
src/frontend/e2e/samples/widgets/button.spec.ts— Added keyboard shortcut Playwright testsCommits
706685ac9— Fix keyboard shortcuts on Mac by using event.code instead of event.keybc8a11d80— Add Alt/CMD shortcut test cases and Playwright tests