Skip to content

fix(key_codes): add Function key arm so macOS fn can be bound to a chord#950

Open
sridhar-3009 wants to merge 1 commit into
jamiepine:mainfrom
sridhar-3009:fix/macos-fn-key-chord-941
Open

fix(key_codes): add Function key arm so macOS fn can be bound to a chord#950
sridhar-3009 wants to merge 1 commit into
jamiepine:mainfrom
sridhar-3009:fix/macos-fn-key-chord-941

Conversation

@sridhar-3009

@sridhar-3009 sridhar-3009 commented Jul 22, 2026

Copy link
Copy Markdown

Fixes #941.

Problem

key_from_str() in tauri/src-tauri/src/key_codes.rs had no arm for "Function", so it fell through to None. build_chord propagates that None as a hard Err via ?, so any chord containing fn made build_chord_bindings fail entirely — HotkeyMonitor was never spawned, silently disabling both push-to-talk and toggle-to-talk until the chord was changed back to a mapped key. No error is logged either, since the failure happens before the "ChordMatcher build failed" log line would run.

Every other layer already supports it:

  • keytap::Key::Function exists (confirmed in jamiepine/keytap's src/key.rs)
  • keytap's macOS key tap already observes it (kVK_FunctionKey::Function)
  • the frontend's canonicalKeyFromEvent/displayLabelForKey already allowlist/label 'Function''fn'

Only this string→Key bridge was missing the arm.

Fix

One arm, exactly as suggested in the issue:

"Function" => Key::Function,

Testing

There's no existing test suite for key_codes.rs (no #[test] module in the file), so I didn't add test scaffolding beyond the scope of this one-line fix. I don't have a Mac to verify the chord end-to-end, but the fix is a direct, mechanical addition matching the pattern of every other key arm in the same match block.

Summary by CodeRabbit

  • Bug Fixes
    • Improved keyboard shortcut handling by recognizing the canonical “Function” key name when restoring saved key combinations.

key_from_str() had no arm for "Function", so it fell through to
None. Since build_chord propagates that as a hard Err via ?, binding
any chord containing fn made build_chord_bindings fail entirely —
HotkeyMonitor was never spawned, silently killing both push-to-talk
and toggle-to-talk until the chord was reverted.

Every other layer (keytap's macOS key tap, Key::Function itself, the
frontend's canonicalKeyFromEvent/displayLabelForKey) already handles
fn — only this string-to-Key bridge was missing the arm.

Fixes jamiepine#941
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e2ce18af-50c8-44f5-8fd4-d462f07eb18b

📥 Commits

Reviewing files that changed from the base of the PR and between 52f8d8d and 2b8cd19.

📒 Files selected for processing (1)
  • tauri/src-tauri/src/key_codes.rs

📝 Walkthrough

Walkthrough

Changes

Function key support

Layer / File(s) Summary
Function key string mapping
tauri/src-tauri/src/key_codes.rs
key_from_str now maps "Function" to keytap::Key::Function for chord persistence and reconstruction.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the key change: adding Function key support for macOS chord binding.
Linked Issues check ✅ Passed The change restores the missing Function-to-Key mapping required to let macOS fn chords build successfully.
Out of Scope Changes check ✅ Passed The PR is narrowly scoped to the missing Function key arm and introduces no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS: fn cannot be bound to a capture chord — key_from_str has no "Function" arm, and the resulting Err disables all hotkeys

1 participant