George Garside Blog

A place of many ramblings about macOS and development. If you find something useful on here, it's probably an accident.

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.

  1. 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/
  2. Make a backup of the relevant keyboard file for your locale. In my case, this is Keyboard-en.plist or Keyboard-en_GB.plist.
  3. Add custom characters or change the characters that you wish, then save the file.
  4. 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)

Leave a Reply

1

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!

Reply
2

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.

Reply
0

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...

Reply
0

I can't find the files on both paths in macOS Ventura. Did it changed places again?

Reply
0

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?

Reply
0

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!

Reply