Switch keyboard layouts with the Fn/Globe key and start typing immediately—without waiting for macOS to finish its built-in input-source animation or delay.
macOS can assign “Change Input Source” to the Fn/Globe key, but the change may arrive late enough that the first quickly typed character uses the old layout. This Hammerspoon script handles the transition synchronously:
- Tap Fn to select the next enabled keyboard layout.
- If a printable key arrives before Fn is released, switch first and deliver that physical key in the new layout.
- Keep Fn+F1–F12, arrows, Return, Tab, Delete, and combinations with other modifiers working normally.
The implementation never deletes keyboard events and never posts synthetic keyboard events. When necessary, it only removes the Fn flag from the original printable-key event before allowing that event to continue.
- macOS
- Two or more keyboard layouts enabled in System Settings → Keyboard → Text Input
- Hammerspoon with Accessibility permission
-
Install and launch Hammerspoon:
brew install --cask hammerspoon
-
In System Settings → Privacy & Security → Accessibility, enable Hammerspoon.
-
In System Settings → Keyboard, set “Press Fn/Globe key to” → “Do Nothing.” This prevents macOS and the script from both switching the layout.
-
Use this repository's
init.luaas~/.hammerspoon/init.lua:mkdir -p ~/.hammerspoon cp init.lua ~/.hammerspoon/init.lua
If you already have a Hammerspoon configuration, copy the script into it instead of overwriting your existing file.
-
From the Hammerspoon menu-bar icon, choose Reload Config. You should see “Fast Fn language switching is active.”
Optionally enable Launch Hammerspoon at login in Hammerspoon Settings.
- Tap Fn/Globe: switch to the next enabled keyboard layout.
- Fn then a printable key, without waiting: switch first, then type that key in the new layout.
- Fn+F1–F12 or another non-printable key: retain normal Fn behavior and do not switch layouts.
- Fn plus another modifier: retain the original shortcut behavior and do not switch layouts.
With more than two enabled keyboard layouts, Fn cycles through them in the order returned by macOS.
Press Control+Option+Command+Escape (⌃⌥⌘Esc) to stop the switcher until the Hammerspoon configuration is reloaded or Hammerspoon restarts.
- Hammerspoon cannot observe keyboard events while macOS Secure Input is active, such as in some password fields.
- Keyboard utilities that also remap Fn may conflict with this script.
- The physical keycode set targets standard ANSI/ISO Mac keyboard character positions.