OSX tip: Using the capslock key to toggle iTerm

Updated September 2025, replacing PCKeyboardHack with Karabiner-Elements

This little nugget was shared on some internal mailinglist, but deserves more attention. And as usual, blogging about it is a good way for myself to find it again.

The idea is to remap the capslock key to toggle the iTerm window, no matter what window is currently focused. Pressing capslock again will hide iTerm, putting the previous window back on top.

To start with, install Karabiner-Elements. Follow their instructions for installation, changing the capslock key to some other keycode (getting to that in a second) and disable the default behaviour.

Now, the suggested use was as an iTerm hotkey. For that, set the keycode to 105 (F13). Then go to Preferences in iTerm, and enable the system-wide hotkey (click into the input, then press your newly assigned caps lock key, it should input F13).

Screenshot of the iTerm2 Settings window with the Keys/Hotkey configuration and Karabiner-Elements Settings window behind it.
-Jörn