Matt Kirman

Mac: How to Rebind Caps Lock to Control

With the increasing time that I’m spending in Tmux and Vim I’ve come to realise that the positioning of the control key is far from comfortable when working for a period of time. On the other hand I rarely use the ergonomically positioned caps lock.

Remapping the caps lock key is becoming an increasingly common modification in the Vim community. Thankfully it’s extremely easy to set up on OS X - with no third party software required.

Tucked away in the Keyboard section of System Preferences there is the Modifier Keys section. You can then just change the value in the Caps Lock key dropdown to ‘^ Control’.

OS X Modifier Keys dialog

Some users report that they encounter a slight delay on the caps lock key when using this method but I can’t replicate this issue in Mountain Lion.

I’ve converted the above process into an Applescript so that I can run it automatically when setting up a Mac from scratch. Once I’ve cloned and installed my dotfiles Git repo (mattkirman/dotfiles) it’s as simple as running $DOTFILES_DIR/osx/

The Applescript:

tell application "System Preferences"
	set current pane to pane ""
end tell

tell application "System Events"
	tell application process "System Preferences"
		get properties
		click button "Modifier Keys…" of tab group 1 of window "Keyboard"
		tell sheet 1 of window "Keyboard"
			click pop up button 4
			click menu item 2 of menu 1 of pop up button 4
			click button "OK"
		end tell
	end tell
	tell application "System Preferences" to quit
end tell

You can download and run this script from mattkirman/dotfiles/blob/master/osx/capslock-to-control.scpt.