Karabiner-Elements (10.12 and later)
Karabiner stopped working in 10.12 due to changes in the kernel architecture, and Karabiner was rewritten as Karabiner-Elements which uses a new JSON format for the configuration files.
You can now add a rule like this to
"shell_command": "open -a terminal"
This makes a short press of the right command key open Emacs:
"shell_command": "open -a emacs"
Karabiner (10.11 and earlier)
Save a file like this as
<autogen>__KeyToKey__ KeyCode::F11, KeyCode::VK_OPEN_URL_Safari</autogen>
<!-- change the right option key into an extra modifier key -->
<autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::VK_MODIFIER_EXTRA1</autogen>
<autogen>__KeyToKey__ KeyCode::I, ModifierFlag::EXTRA1, KeyCode::VK_OPEN_URL_iTunes</autogen>
<!-- make a short press of the right command open Emacs -->
<autogen>__KeyOverlaidModifier__ KeyCode::COMMAND_R, KeyCode::COMMAND_R, KeyCode::VK_OPEN_URL_EMACS</autogen>
If you have bought the Powerpack for Alfred 2, you can create a workflow like this:
Hotkeys have a short delay by default, but you can reduce the delay by changing the "Trigger behaviour" option from "Simulate modifier keys released" to "Pass through modifier keys (Fastest)":
Open Automator, select "Service" as the type of the document, change "Service receives" from "text" to "no input", add a "Launch Application" action, and save the service.
Then assign a keyboard shortcut for the service from System Preferences > Keyboard > Shortcuts > Services.
I don't recommend this option, because at least on my system, there is at best a delay of around half a second before an application is focused by a keyboard shortcut created using this method, and the delay is often even longer. There has also been a bug since 10.7 where the keyboard shortcuts for Automator services don't always work until you hover over the services menu from the menu bar. (Edit: it's now 8 years after I wrote this answer and the bug still hasn't been fixed.) Also, the keyboard shortcuts for services are not available in some applications like Emacs.