When holding down a character on the keyboard in OS X, a popup appears with accented characters that you can use. If you don’t want to remember all the keyboard shortcuts for the accents, this provides an easy way to access them. However, you can add custom characters to these popups to include your own characters and even strings by customising the PressAndHold.app.
- Navigate to
/System/Library/Input Methods/PressAndHold.app/Contents/Resources/
.
In macOS Sierra, this path has changed. The path is now/System/Library/Input Methods/PressAndHold.app/Contents/PlugIns/PAH_Extension.appex/Contents/Resources/
- Make a backup of the relevant keyboard file for your locale. In my case, this is Keyboard-en.plist or Keyboard-en_GB.plist.
- Add custom characters or change the characters that you wish, then save the file.
- Log out and back in for the changes to take effect in all apps.
Here’s my custom characters that I’ve added to my Keyboard-en.plist. This is updated automatically when changes are made to the file on my Mac. The file is also used on my jailbroken iPhone.
<!-- q: OS X symbols -->
<key>Roman-Accent-q</key>
<dict>
<key>Direction</key>
<string>right</string>
<key>Keycaps</key>
<!-- All the symbols I need for writing answers on Ask Different! -->
<string>⌘ ⌥ ⇧ ⌃ ⎋ ⏏ ⌫ ⇥ ↩︎ ⇞</string>
<key>Strings</key>
<string>⌘ ⌥ ⇧ ⌃ ⎋ ⏏ ⌫ ⇥ ↩︎ ⇞</string>
</dict>
<!-- w: arrows -->
<key>Roman-Accent-w</key>
<dict>
<key>Direction</key>
<string>right</string>
<key>Keycaps</key>
<string>→ ← ↑ ↓</string>
<key>Strings</key>
<string>→ ← ↑ ↓</string>
</dict>
<!-- r: misc -->
<key>Roman-Accent-r</key>
<dict>
<key>Direction</key>
<string>right</string>
<key>Keycaps</key>
<!-- That's a double prime, not speech marks
also, the degrees celsius is a single unicode character
I rarely use these arrows in comparison to the ones above -->
<string>″ ✓ ✗ ▶︎ ◀︎ ℃ ©</string>
<key>Strings</key>
<string>″ ✓ ✗ ▶︎ ◀︎ ℃ ©</string>
</dict>
<!-- v: math symbols -->
<key>Roman-Accent-v</key>
<dict>
<key>Direction</key>
<string>right</string>
<key>Keycaps</key>
<!-- I use therefore/because and not equal to much more than any
of the other characters here -->
<string>× ÷ √ π ∴ ∵ ≈ ≠ ∞</string>
<key>Strings</key>
<string>× ÷ √ π ∴ ∵ ≈ ≠ ∞</string>
</dict>
<!-- t: unicode superscript numbers -->
<key>Roman-Accent-t</key>
<dict>
<key>Direction</key>
<string>right</string>
<key>Keycaps</key>
<string>¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁰</string>
<key>Strings</key>
<string>¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁰</string>
</dict>
Code language: HTML, XML (xml)
Hi! I would like to use this method to add this function to an ethiopic keyboard but I am not sure which one of those in the directory it is. I have installed the keyboard layout for ethiopic normally in my keyboard layouts, is this list also updated consequently or do I have to create a new keyboard-ethiopic.plist? how is this linked to the actual keyboard? thanks a lot!
Exactly what I was wondering! Too bad nobody has responded.
I've taken a look at most of the .plist files and I think I may have figured out what needs to be done. But I haven't tried it yet. It looks like the files are linked to language and not keyboard layout. So you could pick one of the files, copy it to your documents folder or something, rename it... "keyboard-am_ET.plist" seems like a good first try (maybe leave off the ET if you're not in Ethiopia?). You should probably also check whether the keyboard you're using is programmed with a target language- many of the Ethiopic layouts are not. However, there is a free tool called Ukelele that you can use fairly easily to encode the language.
Then you just begin editing the file. It looks quite straight forward- open up several of the plist files, especially for languages using foreign scripts, to see what you need to do if you don't fully understand. Something like the "Special Characters" app would be helpful. I would recommend using something like "PListEdit Pro" to help make sure all the formatting/encoding details are correct. Maybe start off with one set of characters to see if it works. (You'll have to figure out on your own how to deal with the security/permissions issues adding your plist to the Press and Hold app).
I'm going to play around with this and see if I can get it working. I'm also working on (nearly finished) with a keyboard layout that is actually a double functioning keyboard for Ethiopic and Latin! The Ethiopic glyphs are accessed by pressing CapsLock (whose traditional function is sacrificed/lost) so you can easily tell with the CapsLock LED indicator which set of letters will be produced- but you don't have to change layouts! I'll check back here once I have more to report. If I can get it working, I'd be happy to share the files with you if you're interested.
Actually, I think I am just going to add the Ethiopic syllables to "Keyboard-default.plist". That way the candidates should pop up regardless of the language or input method, but they still will only appear if/when a base or 6th form Ethiopic syllable is typed. That seems like a good solution...
Thank you for your very detailed comment! I have no idea how PressAndHold app is aware of the plists — there doesn't seem to be an 'index' plist (or at least I can't find one) which would provide a list of the plists given. Did you try adding a new plist for a locale and was it successful? As you mention in your next comment, the default plist is also a way forward if the specific plist didn't work. I guess I could have recommended this in the post rather than editing the specific one, I just didn't want to pollute the default plist on my own machine.
I see Ukelele recommended all the time on Stack Exchange for editing keyboard layouts (never used it myself). It does seem good for this kind of editing. I like the look of your recommendation of PlistEdit Pro. In general, I use TextMate for this kind of block editing of plists, and Xcode (which I have installed anyway) for editing plists in a GUI.
I look forward to hearing how you get on. You are welcome to write a guest post here with your findings and to share the files as I'm sure it will help plenty of people looking for this information. I've not done much in-depth research into this area — let me know how it goes!
It seems to me that Apple has been 'hiding' more and more 'bits' of OS in binary files whose human-readable contents can't (easily) be seen or edited. I suspect such a scenario with the selection of .plists if it's not automatically/dynamically selected based on the current locale/language/IME/keyboard settings, falling back to the default if nothing is found.
I'm curious about your concerns regarding 'polluting' the default plist; were you thinking about the file taking longer to load, using more memory? I'm curious because it's not something I would have thought about. In any case, I went with editing the default to be sure that my edits would always work—since I wasn't fully clear on how it all worked. However, I abandoned working with "PressAndHold" all together because I found that it was slowing me down and didn't offer any benefits for me personally.
Ukelele is a great tool. It's quite easy to use and has an intuitive interface. You can easily start from any keyboard in the system and quickly make a few changes or add more characters to a dead key. Even starting from scratch is no big deal. Dead keys are very easy to create; most of the interface is drag-and-drop compatible with apps like Character viewer (for adding unicode characters to the layout). Plus, the developer and users are very helpful on the support forum.
I haven't used Xcode for editing plists in so long I don't recall exactly why I chose PlistEdit Pro instead but obviously its features and appearance were preferable to me. It certainly has improved since I first began using it as well, especially for working with any plists defined by a DTD—it automatically contains and suggests all the various types of keys with the proper type of data, and it's very easy to reorganize the keys and copy them between files. It also has a dual-view window to see the xml version while editing in a more automated and intuitive GUI. I think it's definitely worth a try.
I've been busier this summer and haven't been able to work as much on these projects, and I've also gotten side-tracked with the creation of a new OpenType Ethiopic font which supports many characters, symbols and variants in addition to all the characters supported by Unicode. In addition to fairly standard features like class-based kerning and mark/accent positioning, I'm working on including features unavailable in any Ethiopic font I've encountered. I am also including all of the Latin-based and phonetic characters used by all of the systems/standards that I can find reference to which are used to transliterate languages which use the Ethiopic script. This font is a prerequisite to the keyboard layouts and "PressAndHold" additions I intend to create and make available with the font.
But my free time is limited as is my knowledge of creating fonts—especially encoding their OpenType features which can become rather complex. So, the project is moving rather slowly for now...
I can't find the files on both paths in macOS Ventura. Did it changed places again?
I have an issue with PAH.app.
It stops and asks for a report or ignore and run wrongly again.
4ever.
Is it possible to copy the app over the installed one?
How can I do it? And where to get it?
Hey there, I stumbled upon your text by chance. Does this trick still work for you?
For some reason, I could not get the accent pop-up to show even after editing the default keyboard plist. I wonder if something has changed in the system in order to prevent this from working.
Take care!
Hi! Yes, it still works for me in macOS Catalina beta. Perhaps try editing the keyboard file more specific/general for your keyboard? For example, I have a GB keyboard which uses en and en-GB plist files; if you are in a similar position try editing the other file from the pair to the one you're trying now.
Apologies for my ignorance, but how did you get past the read-only barrier in Catalina? I just upgraded and I am finding this very annoying.
No apologies necessary! Mount root as read/write to make changes:
It worked beautifully. Thanks for the help!
I am not very familiar with all these files and documents, but I managed to find the .plist file. So I made a copy just to be sure, entered all the changes but now I can't replace the original plist file because it's read only. How/where do I enter this sudo code you mentioned? And do I need to reset this change somehow afterwards? Thanks for the help, if it works it will be a lifesaver! 🙂