Updated: This configuration no longer works in macOS Sierra or greater due to changes in Karabiner. I’ve written some new instructions.
This is a companion discussion topic for the original entry at https://brettterpstra.com/2012/12/08/a-useful-caps-lock-key