fix(macos): track Fn flag bit in FlagsChanged handler#3
Conversation
v0.3.0 added Key::Function (kVK_Function, keycode 63) to the keycode table, but flag_bit_for_key() never got the matching branch, so every Fn FlagsChanged event fell through to the _ => 0 fallback arm and was silently dropped, making Fn unobservable on macOS. Map it to kCGEventFlagMaskSecondaryFn (0x800000), mirroring how the other modifiers are tracked.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds support for the macOS Fn (Function) modifier key in ChangesFn Modifier Recognition
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Problem
On macOS the Fn key is completely unobservable — pressing it produces no
KeyDown/KeyUpevents, even thoughKey::Functionexists andkVK_Function(keycode 63) is already mapped in the keycode table.Root cause
Key::Functionis mapped in the keycode table (63 => Key::Function), butflag_bit_for_key()insrc/platform/macos/tap.rshas no matching arm. So every FnFlagsChangedevent falls through to the_ => 0fallback and is silently dropped:Fix
Map
Key::FunctiontokCGEventFlagMaskSecondaryFn(0x800000), mirroring how the other modifiers are tracked:Verification
Verified locally on macOS: pressing Fn now emits
KeyDown(Function)/KeyUp(Function)events (previously nothing was emitted). Other modifiers are unaffected.Summary by CodeRabbit