macOS dictation key (F5)
On modern Apple keyboards the F5 key is the dedicated Dictation key (microphone icon, between Spotlight and Do Not Disturb). Echophrase uses it as the record toggle on macOS without asking the user to turn off system Dictation, and only while the app is running.Why you cannot just bind F5
The Dictation key does not emit a normal F5 keycode. It emits a HID Consumer-page usage,0xc000000cf (“Voice Command”), which macOS routes straight into its Dictation service before any app sees a keystroke.
tauri-plugin-global-shortcut(CarbonRegisterEventHotKey) binds virtual keycodes and never sees the bare press.- A
CGEventTapcannot reliably swallow it either; macOS handles the key above the tap layer while system Dictation is on.
The approach: remap to F13 with hidutil
The key is remapped at the HID layer to an otherwise unused key, F13 (0x700000068), using hidutil. The app binds F13 as a normal global shortcut and displays it as “F5”, the label printed on the key.
- No System Settings change, no driver, no special permission and no restart.
- A remap takes effect on the next keypress and is cleared on reboot.
- It is session-only and driven by the binding, so native Dictation is disabled only while the user actually has the mic key bound.
Binding-driven lifecycle
If the app is hard-killed the remap lingers until the next launch reconciles it, or until a reboot. Manual recovery:
scripts/mac/dictation-key-revert.sh.
Defaults and display
- The macOS default record hotkey is
f13(DEFAULT_HOTKEY_MACinsrc/lib/utils/hotkeyStorage.ts, and the default insrc-tauri/src/settings/mod.rs). Other platforms default toctrl+shift+space. Because the default is F13, the remap is enabled on first run and the mic key works out of the box. - The binding is stored and registered as
f13but rendered as “F5” byformatKeyToken()insrc/lib/utils/hotkeyFormatter.ts. - During hotkey capture, a remapped mic-key press (
f13) and a plainf5(for examplefn+ F5, or a keyboard without the mic key) are both normalized tof13byhandleHotkeyRecording()insrc/lib/composables/useHotkeys.ts.
Code map
Manual testing
dictation-key-status.sh should show Src 0xc000000cf -> Dst 0x700000068 while the remap is active.
Known limitations
revertclears the entirehidutilUserKeyMapping, so it would also remove any other manualhidutilremap set in the same session. A fuller version would read, merge and write the existing mapping instead.- The legacy “press
fnor Globe twice” Dictation gesture is a separate timing path and is not affected by this remap.