Repository navigation
fix(macos): set the Fn flag on emulated F-keys - #524
Open
ShimmerGlass wants to merge 1 commit into
Open
ShimmerGlass wants to merge 1 commit into
ShimmerGlass wants to merge 1 commit into
Conversation
Hardware F-keys on macOS carry kCGEventFlagMaskSecondaryFn, and System Settings stores F-key shortcuts with that modifier (NSEventModifierFlagFunction, 8388608). Emulated F-keys were posted without it, so shortcuts bound to them never fired, e.g. a screenshot bound to F13, which is what Print Screen from a Linux/Windows sender maps to since feschber#445.
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
Emulated F1–F20 key events on macOS are now posted with the Fn (SecondaryFn) flag, so shortcuts bound to F-keys in System Settings fire.
Changes
input-emulation/src/macos.rs: addMAC_FUNCTION_KEYSandis_function_key, and setCGEventFlagSecondaryFninkey_eventfor F1–F20, mirroring the existing arrow-key handling.function_keys_are_recognized.Scope notes
defaults read com.apple.symbolichotkeysshows e.g.(65535, 105, 8388608)for F13), and real Apple keyboards set SecondaryFn on F-keys. Emulated F1–F20 lacked the flag, so symbolic hotkeys never matched. Raw-keycode tools like skhd don't check the flag, which is why macos: map Print Screen / Scroll Lock / Pause to F13/F14/F15 #445's testing didn't catch it.Verification
function_keys_are_recognizedadded.cargo test -p input-emulation,cargo fmt, andcargo clippy --workspace --all-targets --all-featurespass. Only pre-existingmust_usewarnings ininput-capture/src/lib.rsandinput-emulation/src/lib.rsremain.No issue number is associated with this change.
🤖 Generated with Claude Code