I am aware that when I press ⌥ or ⇧⌥ on my Mac, I can type a variety of special characters. I also know that I can insert special characters using the character palette. Is there a way to expand the number of special characters I can type while using the keyboard? I am particularly interested in solutions that work in Lion and Mountain Lion.
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:
To set this up, you just create the file
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
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:
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 ⌥+⌘+T.
|show 1 more comment|
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).
You can design a custom keyboard layout, which will appear in the input source list next to U.S. and Dvorak and Turkish and all that. You can arbitrarily change what character(s) are produced for any key with any combination of modifiers, and multi-character combinations (which in this context are known as “dead keys”, such as Optione which makes acute accents, but can be much more general than that).
Ukelele is a free program for editing keyboard layouts. I use a keyboard layout of my own design, which notably adds dead keys for typing mathematical symbols and Greek letters (without switching to a Greek keyboard layout).
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:
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:
Right click on this file, and select
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:
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
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.
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
Seeking similar functionality on iOS, I also created a set of TextExpander snippets which I can access from my iOS devices or any Mac to which I sync my TextExpander settings. (I currently use DropBox to do so.) This is arguably faster than editing the plist file when I first "take control" of a new machine, and is less intrusive on Macs that I'm just borrowing.
Below is my list of snippet shortcuts followed by the character (or entity) that it expands to:
There are some important gotchas with the other solutions posted here. I’ll explain them, and offer an alternate solution that avoids these issues.
For one, symbol and text substitution entries only work in Cocoa apps. If you want a truly system-wide solution that works in all applications, this is not an option.
Also, apps like KeyRemap4MacBook are great, but relying on them means you have to keep the app running in the background all the time, which may not be what you want.
Custom keyboard layouts to the rescue
Luckily, remapping keys can be done in a way that will work for any type of application, and without any additional software!
Mac OS X has supported
How to create a custom keyboard layout
To create new keyboard layouts or modify existing ones, I’d recommend Ukelele.app. It has an option to create a new keyboard layout based on the one that’s currently in use.
After you’ve created your custom layout, there’s no need for the application anymore — you certainly don’t need to keep it running in the background.
How to install a custom keyboard layout
How to make a custom keyboard layout the system default
Optionally, you could make the custom keyboard layout the system default by running the Setup Assistant with root privileges. This way, it will be used for the login screen, and any new user accounts you create will default to this layout as well. Note that this can only be done for keyboard layouts in
You will have to create a new user account in order to complete the Setup Assistant — but don’t worry, you can delete the new account afterwards.
Adding a custom icon to the keyboard layout
OS X will use the following default icon for your custom keyboard layout:
This icon will show up in the preference pane, and in the “Input menu” in the menu bar.
To replace this with your own icon, create a 16×16px image, and save it in