Obviously, if English isn’t your first language, you end up switching keyboard
layouts a lot. On just about every system except macOS, that usually means using
a keyboard shortcut. I think Caps Lock is the easiest key to reach. On Linux,
all you need is a setting like grp:caps_toggle. Macs have a dedicated Globe
key (๐/Fn). Good idea, but I still have to stretch my pinky to reach it. It
sometimes misses presses, too, because of delays in how special keys are
handled. Caps Lock also has an LED that can show you which layout is active.
That’s what Linux does by default when you set Caps Lock to switch layouts.
Of course, Apple has already decided for you, so there’s no easy fix. Time to dig out the duct tape. First up, let’s get Caps Lock to switch layouts.
macOS has a built-in setting to switch layouts with Caps Lock. There’s a catch,
though. It handles special keys in a weird way, so if you start typing right
after pressing Caps Lock, the layout just doesn’t switch. Maybe the system
thinks it was an accidental tap or is waiting for a key combination. As usual,
macOS thinks it knows better than you. I tried getting rid of the delay with
hidutil property --set '{"CapsLockDelayOverride":0}'. No luck.
So I went the long way around and remapped Caps Lock to F18 (or another function
key). I started out with
Karabiner-Elements, but hidutil itself
turned out to be a cleaner way to do it, with no extra software. macOS then
sees a regular keypress, and the weird delay goes away.
Remap Caps Lock to F18
Here’s the command.
| |
Unfortunately, the remap only lasts until you reboot, so let’s have launchd
apply it.
Create the agent file at ~/Library/LaunchAgents/com.local.caps-to-f18.plist.
| |
Now load the agent into the current session.
| |
Set F18 to switch layouts
Now let’s tell macOS to use F18 to switch layouts.
- In System Settings โ Keyboard โ Text Input โ Edit, turn off the built-in Caps Lock layout switch if it was enabled.
- In System Settings โ Keyboard โ Keyboard Shortcuts โ Input Sources, enable Select next source in Input menu. Click the shortcut on the right and press Caps Lock. It should register as F18.

Use the LED to show the active layout
Install and launch Hammerspoon with Lua support
by following the setup instructions.
Add this snippet to ~/.hammerspoon/init.lua and choose Reload Config from
the Hammerspoon menu. The LED stays off for the U.S. layout and lights up
for every other input source.
| |

