Skip to content

Let macOS Globe actions work when hold-to-talk is Fn - #369

Draft
marcbodea wants to merge 4 commits into
mainfrom
takeover/304-fn-globe-passthrough
Draft

marcbodea wants to merge 4 commits into
mainfrom
takeover/304-fn-globe-passthrough

Conversation

@marcbodea

Copy link
Copy Markdown
Collaborator

Closes #303

Supersedes #304 — based on work by @foxswat (original commits cherry-picked with authorship preserved).

User-facing fix

When Hold to Talk is set to Fn, FreeFlow swallowed every Fn/Globe key event. macOS never saw the key, so Press 🌐 key to → Change Input Source / Show Emoji & Symbols stopped working while FreeFlow ran, even for quick taps.

Now, with Hold to Talk = Fn:

Gesture Before After
Quick Fn tap Recording starts (or nothing with a start delay); Globe action never fires macOS performs the Globe action; no recording
Fn hold ≥ 200 ms Dictation Dictation (unchanged)
Cmd+Fn (default toggle) Toggle dictation, event consumed Unchanged
Double tap Fn (Double-tap to lock on) Locks recording Locks recording; only the first tap reaches macOS

How it works

  • ShortcutMatcher: bare Fn events no longer get consumed on behalf of the hold binding, so macOS sees them. Toggle bindings that use Fn still consume. When a snapshot only repairs a missed Fn hold state, it passes through, so the ordinary key event that carries it isn't dropped.
  • Start floor: Fn hold-to-talk waits at least 200 ms before it starts recording (max(userDelay, 0.2)). A tap released before then cancels the pending start through the existing path. Longer user delays are kept. Non-Fn bindings and toggle starts keep their configured delay.
  • Double-tap lock (Add double-tap on the hold shortcut to lock recording #349): DictationShortcutSessionController.claimsHoldShortcutPresses is true while the controller waits for the second press, and while a recording is locked by double tap. HotkeyManager reads it when each new Fn press starts. A claimed press is consumed for both its down and up events, and an unclaimed one passes through for both. macOS never sees half a press.

Changes vs #304

  • Rebased onto current main, including Add double-tap on the hold shortcut to lock recording #349's double-tap lock.
  • Dropped the CHANGELOG.md edit, as the maintainer asked.
  • Moved the start-delay policy out of AppState into ShortcutCore/ShortcutStartDelayPolicy.swift so tests can cover it deterministically, as the maintainer asked. It's added to TEST_PRODUCTION_SOURCES.
  • New: the Fn claim during double-tap sessions. Without it, every press of a double-tap lock, and the press that stops a locked recording, would also fire the Globe action. With Globe set to Change Input Source, the input source would flip on every press. Where macOS uses "press Globe twice" for Apple Dictation, the double tap would also start Apple Dictation.
  • DictationShortcutSessionController.beginManual is untouched (Stop a menu-bar toggle session on the first shortcut press #360 edits it).

Tests

make check and git diff --check pass.

  • testBareFnHoldLifecycle was updated, and these came from Let macOS Globe actions work when hold-to-talk is Fn #304: testBareFnToggleStillConsumes, testFnHoldPassthroughUnlessToggleComboActive, testSnapshotRepairFnHoldDoesNotConsume.
  • testFnHoldStartDelayPolicy: Fn gets the 200 ms floor, longer user delays are kept, Fn-as-modifier bindings get the floor, and non-Fn, toggle and disabled bindings keep their delay.
  • testQuickFnTapCancelsPendingStart: a release before the floor ends the session with .stop, which cancels the pending start.
  • testClaimedFnPressDecisionIsStickyPerPress: the decision made on Fn down also applies to that press's Fn up. Non-Fn hold keys are unaffected.
  • testBackendResetClearsFnClaim
  • testFnDoubleTapLockClaimsOnlyFollowUpPresses: runs the matcher and controller end to end. The first tap passes through; the latching press and the stop press are consumed; the next ordinary tap passes through.
  • testFnQuickTapPassesThroughWithDoubleTapEnabled: a single tap passes through and times out without recording, and a long hold passes through.
  • Mutation check: if the claim is ignored, the double-tap test fails.

Manual test: pending

These need an Apple keyboard with a Globe key. Use invented speech only and put no private content in the report. Record the macOS version and the Globe system action you set.

  • Quick Globe tap → input source changes, or emoji picker opens, per System Settings; no recording
  • Long Fn hold → dictation records and transcribes; no stray Globe action
  • Cmd+Fn → toggles dictation normally
  • Double tap Fn with Double-tap to lock on → recording locks; Globe action fires at most once (first tap); next Fn press stops; that press triggers no Globe action
  • Event-tap re-enable (e.g. after sleep/secure input) → Fn hold still works and ordinary typing isn't swallowed
  • Non-Fn hold shortcut (e.g. Right Option) → unchanged, including double tap

Shortcut risk notes

  • This weakens consumption only for bare Fn events on the hold binding. Exact matching of the hold binding is unchanged, and toggle and Paste Again consumption are unchanged. The regression tests above cover it.
  • Because Fn now reaches macOS during a hold, a press of roughly 200 ms can trigger both a Globe action and a recording, depending on macOS's tap threshold, which isn't documented. Behaviour for this window is part of the manual test.
  • The first tap of a double tap still reaches macOS, because nothing can tell it apart from a plain Globe tap when it happens.
  • The claim is read synchronously on the main run loop when each Fn press starts. Shortcut events reach AppState through DispatchQueue.main.async, which runs well before a human's second press arrives.
  • No new logging, storage, permissions or data transmission.

🤖 Generated with Claude Code

foxswat and others added 4 commits November 23, 2026 16:43
Fixes #303.

When hold-to-talk is bound to Fn, FreeFlow consumed every Fn
flagsChanged event at its CGEvent tap, so macOS never saw the key and
'Press globe to: Change Input Source' (or any system Globe action)
could never fire -- even for quick taps far too short to be push-to-talk.

Two changes:

- ShortcutMatcher: Fn/Globe (keyCode 63) modifier events are no longer
  consumed on behalf of the hold binding. macOS ignores long Fn holds,
  so hold-to-talk works identically by passive observation, while quick
  taps now reach the system Globe action. Toggle bindings (e.g. the
  default Cmd+Fn) keep consuming, since a Fn tap is meaningful on both
  sides there.

- AppState: hold-to-talk on Fn gains a 200 ms minimum hold time
  (max of the user's Shortcut Start Delay and the floor), so a quick
  tap released before the floor cancels the pending start instead of
  flashing a recording.

Updated testBareFnHoldLifecycle for the new passthrough semantics and
added coverage for Fn toggle consumption and the default
hold=Fn / toggle=Cmd+Fn interaction. make check passes.
- ShortcutMatcher: a snapshot that only flips Fn hold state (e.g. a
  repaired missing Fn state after the event tap was re-enabled) no
  longer marks the carrying ordinary key event for consumption, so
  GlobalShortcutBackend can't drop that keystroke. Toggle and non-Fn
  hold transitions keep consuming as before. Regression test added.
- ModifierKeyEventState.fnKeyCode now aliases ShortcutBinding.fnKeyCode
  so event production and shortcut matching share one source of truth.
Move the Fn hold-to-talk 200 ms start floor into ShortcutStartDelayPolicy so
it can be tested: Fn holds get the floor, longer user delays are kept, and
non-Fn and toggle starts keep the configured delay.

Fn presses pass through to macOS so quick taps reach the Globe action. With
double-tap to lock enabled, the second press that latches recording and the
press that stops a locked recording now belong to FreeFlow and are consumed
for their whole down/up pair. The first tap still reaches macOS, since it is
indistinguishable from an ordinary Globe tap when it happens.

Co-authored-by: Fox Qi <1661407+foxswat@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hold-to-talk = Fn swallows every Fn/Globe press, so macOS "Press globe to Change Input Source" never fires (even on quick taps)

2 participants