-
-
Notifications
You must be signed in to change notification settings - Fork 463
fix: require a modifier key for keyboard shortcut recording #557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
akshay-soni
wants to merge
2
commits into
altic-dev:main
Choose a base branch
from
akshay-soni:fix/require-modifier-for-keyboard-shortcut
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+73
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the user deliberately holds Globe/Fn and records an F-key, arrow, or navigation key, the
flagsChangedpath has already put.functionintopendingModifierFlags, but this branch strips.functionsolely because of the key code. As a resultFn+F5orFn+Leftis treated the same as a bare auto-flagged key and is rejected with “needs a modifier key,” even though the app otherwise treats Fn as a supported modifier (for exampleFn+Fremains allowed). The guard needs a way to distinguish an explicit Fn press from the auto-injected flag before dropping it.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the record-time half of this is accurate.
pendingModifierFlagsdoes know the difference when Fn is physically held (the flagsChanged handler unions.functionin), and this guard rejects an explicit Fn+F5 / Fn+Left regardless.The problem is that match time can't make the same distinction. The global tap derives modifiers purely from CGEventFlags, and macOS sets
.maskSecondaryFnon bare presses of every function-section key. SoHotkeyShortcut.matches()sees a saved Fn+Left ([.function]+ keyCode 123) as identical to a bare Left arrow press. If we preserved the explicit Fn at record time, the saved shortcut would fire on (and consume) every bare Left press system-wide, which is exactly the #556 breakage this PR is closing. For F-keys the collision depends on hardware and settings: Apple keyboards in media-key mode never deliver a bare F5 keyDown, but external keyboards and "use F1, F2, etc. as standard function keys" mode do, so the recorded shortcut would silently behave differently across setups.Distinguishing a physical Fn hold at match time would mean tracking Fn state in the event tap via flagsChanged (keyCode 63). That gets fragile fast: tap restarts while Fn is held, Globe key remapping, external keyboards that have no Fn key at all. Out of scope for this fix in my opinion.
If F5-style hotkeys are wanted, I think the honest version is the option already flagged in the PR notes: drop the F-key codes from
functionSectionKeyCodesso F-keys are recordable again, accepting that they intercept the bare key, rather than recording a modifier the matcher can't honor. Happy to do either depending on maintainer preference.