Priit Haamer

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

Jan 29, 2013
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/PressAndHold.app/Contents/Resources/Keyboard-et.plist to contain the following (I added bunch of other characters as well): 
<key>Roman-Accent-q</key>
<dict>
  <key>Direction</key>
  <string>right</string>
  <key>Keycaps</key>
  <string>q ` ^ ⌥ ⇧ ⌘ ⎋ ⏏ ⌫ ↑ ⇡ ↖ ⇞ ⇥</string>
  <key>Strings</key>
  <string>q ` ^ ⌥ ⇧ ⌘ ⎋ ⏏ ⌫ ↑ ⇡ ↖ ⇞ ⇥</string>
</dict>  
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 com.apple.terminal 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