Apple - How can I expand the number of special characters I can type using my keyboard?

Custom text entry key bindings

OS X has a very nice text editing system, which you can extend using Key Bindings. You can, for instance:

  • Set up special characters to be entered when you press a certain key command.
  • Insert more than one character at once.
  • Include navigation commands and change the selection.
  • Use multi-stroke key bindings — this is how I type the ⌃⌥⇧⌘ characters.

To set this up, you just create the file ~/Library/KeyBindings/DefaultKeyBinding.dict and put your customizations there. This article describes the steps in detail.

Here's a list of the default key bindings, and here's Apple's official guide to the text system and key bindings.

Diacritics

If you're just looking to be able to type more diacritics, and you use a U.S. keyboard, consider using the U.S. Extended keyboard layout:

This allows you to type such characters as oòôȯóöơōṯțőo̊ɵỏọţǒŏõǫȏṵṷȍ. You can enable it from the Input Sources section of the Language & Text system preferences.

"Press and hold"

In Lion, you can type many special characters by holding down a similar key on your keyboard:

(It turns out this can be customized, if you're up to the task! All it takes is to edit a plist file.)

Arbitrary text substitutions

If you have specific phrases or characters you'd like to use, you can also set up custom substitutions for them in the Text section of Language & Text preferences:

Character palette

I guess you already know this, but I'll include it for completeness. If you enable "Keyboard & Character Viewer" in the Input Sources section of the Language & Text prefs, you can open the Character Viewer and browse through the entire Unicode character set (and you can also browse characters by category):

This window is easily accessible in most applications with ++space (in older versions of OS X, the shortcut was ++T).


In addition to simply using the press-and-hold method included in @jtbandes answer, it is also possible to customise the list of options that you are presented with when you hold down a key. In the example below I configured the "Q" key to show a list of special character codes corresponding to the Mac keyboard:

enter image description here

To do this, you need to be comfortable editing a plist file. If you are not sure what a plist file is, this may not be a suitable procedure to follow, just in case you hit problems.

I used TextWranger, but if you have Xcode you can use Plist Editor, or any other tool that can open and read the plist formatted files.

The first step is to navigate to the following location. You may need to make your Library folder available depending on how you choose to get there:

/System/Library/Input Methods/PressAndHold.app/

Right click on this file, and select show package contents, and head on over to ./Contents/Resources/Keyboard-en.plist - choose the keyboard file relevant to your locale if you are using a different keyboard layout.

I took a copy of this file and dragged it over to my desktop for editing. Also, for sanity, take a copy of the entire press-and-hold.app bundle in case you ruin everything. Editing the file, you can see a series of statements that look similar to the following:

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

In the example above, when holding down the lower case 'a' key, you will get the following alternatives. I included 'b' in the list also. After making the changes and saving the file, I dragged the file back into the press-and-hold bundle into the correct place, and authorised as administrator to allow the copy to complete. To make this available, you need to log out/in to reload the plist. Now just press and hold the key(s) you modified, to see your new list.

You can put anything you like in the alternatives list, just leave a space between each one, and don't bother going above 9 entries if you are a keyboard shortcut junkie, as you cannot select one of the alternatives by typing '10' without just getting '1' instead, even though the numbers above 9 still get listed... Note that as per the above image, you can include unicode characters, emoji, and indeed anything that you can find in the special character palette that is also included in @jtbandes answer

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

For preference, rather than ammend existing entries, I simply tested keys for ones that had no existing alternatives and made a fresh statement in the plist file for those keys as per above. But be careful to check for duplicate statements for the same letter, as likely only 1 will work. Try to keep them in alphabetical order for sanity.

Keys q/Q/z/Z are good options for fiddling with, having no pre-existing alternatives for that particular locale/keyboard that I used. This can give you up to 36 'slots' for creating custom shortcuts to unusual characters. You can have a set of Emoji, a set of Keyboard characters etc etc on any key you like. Likely other characters are also currently free of alternatives, and perhaps using a non-alphanumerix key like ` or @ or ¬ or ~ would be a good choice if you are filling the alternatives list with more non alphanumeric characters, but I don't know currently how you would identify them in the plist - would <key>Roman-Accent-~</key> work? I have no idea, I didn't test that.

Note, take a copy of the plist somewhere, I have no idea if this will be overwritten on subsequent OS updates etc, and it would be a pain to remember what you did and repeat it next month when 10.7.4 is out etc.

It's possible that you can replace with more than a single character also. I didn't try this either. But is anyone fancies adding this <kbd></kbd> to the k assignment, I'd be interested to see what happens :)


If you enable the "Unicode Hex Input" keyboard, you can enter any special character, knowing their Unicode code.

For example, if I press , and I click on 2, 2, 0, and 0, while keeping pressed, I get ∀ (the FOR ALL Unicode character).

screenshot

Tags:

Macos

Keyboard