82

In OS X Lion, there is a very useful feature for people like me who need to write in multiple languages, which pops up a small menu of additional characters when you hold down a letter.

For instance, when I hold down the letter E, I get:

e

This is great when I'm writing in French for example. However right now I need to write something in Czech; however, the Czech letter ě (looks like the 3rd letter in the popup with the accent flipped) does not appear in the popup.

Is there a way to tell OS X to include Czech or other additional characters in those popups?

Note: I do not want to use the Czech keyboard layout; I found switching layouts for each language is somewhat unpractical.

Pro Backup
  • 3,916
houbysoft
  • 9,182

6 Answers6

95

The characters included in the popovers are defined in property lists inside the /System/Library/Input\ Methods/PressAndHold.app/ bundle.

I was able to change à to y by editing /System/Library/Input\ Methods/PressAndHold.app/Contents/Resources/Keyboard-en.plist and logging out and back in.

(note the escape in "Input Method" if you're copy pasting)

<key>Roman-Accent-a</key>
<dict>
    <key>Direction</key>
    <string>right</string>
    <key>Keycaps</key>
    <string>a y á â ä æ ã å ā</string>
    <key>Strings</key>
    <string>a y á â ä æ ã å ā</string>
</dict>

Lri
  • 105,117
  • 26
    How do you keep on finding these hidden gems? Are you an OS X engineer? ;) – Mathias Bynens Mar 21 '12 at 14:17
  • Wow, lots of people have been trying to figure this out since at least last July. Thanks! – Tom Gewecke Mar 21 '12 at 16:57
  • 1
    ‘Input Methods’, ‘PressAndHold.app’…? It couldn’t have been any more obvious. – Debilski Mar 28 '12 at 14:56
  • Wow, I missed this question until now. I will be playing around to see if I can turn something like ~ into a list of my favourite Emoji or special keyboad characters :) – stuffe Apr 20 '12 at 11:11
  • @stuffe Let us know how it goes. I think the possibilities are enormous, e.g. http://m10lmac.blogspot.com/2012/04/new-way-to-make-custom-keyboard-layouts.html – Tom Gewecke Apr 20 '12 at 12:50
  • 14
    And it goes a little something like this.... http://i.stack.imgur.com/Kyx2v.png :) – stuffe Apr 22 '12 at 18:27
  • 1
    This answer cannot be voted up enough times. – Cajunluke Sep 10 '12 at 03:26
  • 4
    I've tried to use this to add squared and cubed characters for press-and-hold on 2 and 3, but I don't know the dictionary key names for the plist. I've tried <key>2</key>, <key>Number-2</key>, and <key>Roman-Accent-2</key> but none of these worked. Is there a list of possible key-names somewhere? – jhabbott Jun 19 '14 at 17:15
  • @jhabbott i wanted to do the same thing and just added it under the lower case "s" for "squared". also, no need to log off / on (in Mavericks at least). this solution is just awesome - trying to think of other things to use it for. – Nathan Beach Aug 12 '14 at 19:28
  • 6
    It seems that this file is no longer editable in El Capitan... – Michiel de Mare Oct 16 '15 at 07:21
  • 4
    @MichieldeMare That’s because of System Integrity Protection, a new feature in OS X v10.11 El Capitan that makes it impossible for even root to write to system folders. As noted in the Wikipedia article though, it can be disabled. – アリスター Nov 12 '15 at 16:10
  • 4
    I've documented the full process here including temporarily disabling System Integrity Protection. – masukomi Dec 14 '15 at 04:05
  • @masukomi, Catalina breaks your process by having read-only files and writable files in separate directories, and then using "firmlinks" to make them look like they are in the same place. If your "Keyboard-en.plist" is in the writable area, you can edit it without disabling SIP. Unfortunately, there is a file by that name in both areas, and the read-only version overrides the writable version. In fact, if I DELETE the read-only version, the pop-ups do not exist! Solution: csrutil enable --without fs and then after reboot, sudo mount -uw / cont'd… – WGroleau Feb 18 '20 at 01:29
  • … (cont'd) you can then edit the read-only version, and reenable SIP. – WGroleau Feb 18 '20 at 01:31
  • 1
    in MacOS 10.14.2 (Mojave) the file is /System/Library/Input Methods/PressAndHold.app/Contents/PlugIns/PAH_Extension.appex/Contents/Resources/Keyboard-en.plist. Remember you need to disable System Integrity Protection for this to work. – Fabien Snauwaert Feb 12 '21 at 10:40
  • 1
    @アリスター AKA not a feature. Hiding this sort of thing behind SIP is beyond stupid. How on earth does this affect the security of someone's device? It's less about integrity for the sake of the user than it is to make life easier for Apple. Damn, I hate what that company has become. Press And Hold is such a killer feature, and they break the ability to extend it all instead of implementing the proper solution of adding a safe, GUI-based interface to extend it. For such an extremely profitable company it's truly disgusting. – Benjamin R Feb 25 '21 at 17:14
  • If my comment inspires you to disable SIP and change your pop-up, _Surprise!_—Apple is going to change it back with Software Update. Grrr! – WGroleau Dec 13 '22 at 18:07
  • Where is this feature in MacOS Montery? – G M Jan 09 '24 at 17:00
19

I know this is a little late, but I feel it's an important contribution: you can not only press-and-hold keys to input special characters; you can also input strings of text. For example, I configured my Keyboard-en.plist file so when I hold the "p" key, I can choose between my first name (which is pretty long), last name, and email address (which is also long). I feel this might be useful to some people, so this is what it looks like:

<key>Roman-Accent-p</key>
<dict>
    <key>Direction</key>
    <string>right</string>
    <key>Keycaps</key>
    <string>p firstname lastname email</string>
    <key>Strings</key>
    <string>p firstname lastname email</string>
</dict>
pasawaya
  • 2,306
  • Cool! Out of curiosity what's your first name if you don't mind sharing? Given how long it waits I'd imagine this would give me a benefit only like upwards of 10-15 chars... My names are pretty short, but it could be useful for the email. – houbysoft Aug 03 '12 at 01:17
  • @houbysoft - You're right. I guess it's not that useful for my name, as mine is only 8 letters long, but for my emails which are upwards of 25 letters long each, it's very useful. – pasawaya Aug 03 '12 at 01:19
  • btw, I just realized, do you know if something like this is possible on iOS? Given the small keyboards on iPhones for instance this could be very useful for those devices. – houbysoft Aug 03 '12 at 01:22
  • @houbysoft - Well you might have heard of text expanders, which you can configure so for example when I type "addr", it will autocomplete my complete address. I just did a quick google search and it looks like there's an iOS text expander app. You can find it here: http://itunes.apple.com/us/app/textexpander/id326180690?mt=8 – pasawaya Aug 03 '12 at 01:57
  • That may be simple, but I'm trying to edit the .plist but it says I don't own the file, so can't edit it... How would I go about editing the file? – OghmaOsiris Aug 28 '12 at 15:57
  • @OghmaOsiris - Could you post the specific error? – pasawaya Aug 28 '12 at 16:40
  • 1
    @OghmaOsiris - Duplicate it, save it to your Desktop, make the desired edits, then rename it to the original (ex. "Keyboard-en-duplicate.plist" -> "Keyboard-en.plist") and place delete the original file. Then place the renamed duplicate in the original directory. – pasawaya Aug 28 '12 at 16:52
6

If you are using macOS Sierra, you need to look elsewhere to change it. Here are my instructions, inspired from Custom Characters in OS X Accent Popup - George Garside:

  1. Disable System Integrity Protection as detailed in How to turn off rootless in Mac OS X El Capitan - MacWorld.

  2. Navigate to /System/Library/Input Methods/PressAndHold.app/Contents/PlugIns/PAH_Extension.appex/Contents/Resources/ in the Finder. To go to it quickly, press ⇧⌘G and paste the string in.

  3. Find your keyboard plist file. If you are using the English layout, you would be looking at Keyboard-en.plist and if you are using the German layout it would be Keyboard-de.plist. It could have other names as well, depending on your keyboard language.

  4. Back this file up by pressing ⌘D. Rename the copy you made to something with "backup" in its name.

  5. Open up the original file (without backup in its name) and edit the characters you want to in. After that, save it.

  6. Enable System Integrity Protection as detailed in the same page as step 1.

grg
  • 201,078
Oion Akif
  • 8,892
5

Using the info in this thread I answered the same question on MacRumors.

I made a custom .plist file specifically for Chinese Pinyin input. So I wanted to link to a plist that is created for Chinese phonetics. You can download it here.

bmike
  • 235,889
3

My solution (for Czech):

  1. Backup /System/Library/Input Methods/PressAndHold.app/Contents/Resources/Keyboard-en.plist file
  2. Copy /System/Library/Input Methods/PressAndHold.app/Contents/Resources/Keyboard-cs.plist and rename it to /System/Library/Input Methods/PressAndHold.app/Contents/Resources/Keyboard-en.plist
  3. Remove useless characters from new /System/Library/Input Methods/PressAndHold.app/Contents/Resources/Keyboard-en.plist
Valon
  • 31
  • 1
  • good idea, I only switch between one other international keyboard ATM, this will make that almost unnecessary!!! (not to mention the layout has me typing with numbers all the time…) – NOTjust -- user4304 May 17 '13 at 17:27
2

I got it to work on OS X 10.11!

Looks like they changed the location to: /System/Library/Input Methods/PressAndHold.app

—> Right Click + Show Package Contents

/Contents/PlugIns/PAH_Extension.appex

—> Right Click + Show Package Contents

/Contents/Resources/Keyboard-en.plist (or whatever keyboard you use).

In there you can click the drop-down arrows, then double click next to "Keycaps" and change the keys to your desired keys. enter image description here

enter image description here

See, it works!

Kris
  • 31
  • Are you sure you are talking about 10.11 El Capitan? In mine, the location of the .plist files is not what you say, but the one in the original answer. If you are really talking about 10.12 Sierra, you should delete this, because it was already fully answered by Skeleton bow months ago. – Tom Gewecke Oct 12 '17 at 04:44