Priit Haamer

Customize Press-and-Hold in OS X for your own good

Jan 29, 2013
Note: The method below cannot be applied any longer on OS X El Capitan or above since modifications to /System directory is not allowed.

While using Estonian keyboard layout on my Macbook i'm short of a few but very important keys in coding such as backtick (`) or caret (^).

So i went and used to copy-paste these characters when needed. But that was a tedious process. Luckily, I got suggestion from a friend that Apple's PressAndHold feature introduced in OSX Lion can be customized. 
All it takes is to edit /System/Library/Input Methods/ to contain the following (I added bunch of other characters as well): 
  <string>q ` ^ ⌥ ⇧ ⌘ ⎋ ⏏ ⌫ ↑ ⇡ ↖ ⇞ ⇥</string>
  <string>q ` ^ ⌥ ⇧ ⌘ ⎋ ⏏ ⌫ ↑ ⇡ ↖ ⇞ ⇥</string>
Note that one needs to modify different files for different keyboard layouts. One gotcha is that it does not work by default in Terminal. In order to enable it, just restart Terminal once you've run this:
defaults write ApplePressAndHoldEnabled -bool true
Unfortunately, TextMate does not support PressAndHold at all, but the ones using sublime just need to run this:
defaults write com.sublimetext.3 ApplePressAndHoldEnabled -bool true