Originally the answer by Martin Steven worked for me. This was when I used OSX 10.9.
After upgrading to OSX Yosemite (10.10) it stopped working. I found another, essentially the same, solution documented here
It uses updated version of the apps (with different names) that work with 10.10.
As requested - quoting the relevant sections from the link
- Install Seil and Karabiner.
- Go to System Preferences > Keyboard > Modifier Keys and change “Caps Lock” to “No Action.”
- Using Seil, check “Change Caps Lock Key” and change the key code to 110. (Application Key)
- Go to Karabiner, and in the search box, enter “application key to capslock.” Under For PC Users > Change PC Application Key, check off “Application Key to CapsLock.”