Home / Mac / How to make a custom keyboard for Mac OS

How to make a custom keyboard for Mac OS


A guide to using Ukelele

Default keyboard layout

In this article, you will create a custom keyboard layout for Mac OS that you can use to enter specific Unicode characters or languages ​​that are not supported.

Mac OS offers many out-of-the-box language options and keyboard layouts. You can find them by going to System Preferences> Keyboard> Input Sources. Then click + plus button to add another.

However, if you speak a minority language or need another special keyboard, you may not be able to find it.

As an example of this, I teach an English phonetics class this concept, and while online keyboards like ipa.typeit.org work well, I need a more convenient solution for typing the International Phonetic Alphabet (IPA) directly on my computer. I also need another keyboard to type traditional Mongolian scripts, which are not included in the keyboard list supported by Mac OS.

To create a custom keyboard, you need to create a keyboard layout package. Ukelele will help you do just that. It is a program created by the well-known linguistics organization SIL International.

Follow when I make the IPA keyboard. You can adjust the steps to meet your own needs.

Find the Unicode symbols

Your keyboard will type Unicode characters, so first of all you should collect the characters you need. Here are some places you can do it:

For me, ipa.typeit.org has most of the special characters I need:


Install Ukelele

Download Ukelele from the official website and install it.

When you open it for the first time, it should look like this:

Empty Ukelele keyboard design

Create a new keyboard layout

This article will teach you how to create a new keyboard layout from scratch. While opening an existing keyboard and editing it can be a faster way to get a finished product, it can be more complicated to understand when creating a keyboard layout for the first time.

Select in the menu File> New keyboard layout.

You will get a popup asking you to enter your name. Since I’m making an IPA keyboard, I’ll give my name IPA. I want to start from scratch, so I choose Empty as a basic keyboard layout. I want command shortcuts like Cmd + C to still work, so I choose QWERTY for the setup with the command key.

Print OK to create your layout.

Then select in the menu File> Save and save it as ipa.keylayout in a place you want. You save it now to make sure you do not lose your job later.

Note: You can also save as a package, but this is not necessary unless you want to do more advanced things like add an icon. For this first keyboard layout, we use only the basics .keylayout file extension, which is an XML file.

You can close the original Ukelele window that appeared when you first opened the application. Just keep an open IPA keyboard layout that you just created.

Double-click a key to edit it

The way to enter a value for a key is to double-click it.

Start by double-clicking on what would be one key on most keyboards and then paste IPA ɑ value that I collected earlier:

Print Finished button to save the change. Your key should now look like this:

You may notice that a single click on a key or pressing a key on the keyboard highlights the key in Ukelele. It does not matter. You can click or press the key again to deselect. By pressing Shift or Command or one of the other modification keys it turns green. You do it later.

If you want to enter a character after the Unicode value instead of pasting it, you can do so by entering the value in XML format. For example, the Unicode hex value of ɑ is 0251. To put it in XML format you will write it like this:


That is, the prefix with the value &#x and end it with ;. (If you use decimal rather than hexadecimal, then quit x.) This is how it looks like entering the hexadecimal value:

Repeat for all the empty keys

Double-click on all the empty keys on the keyboard to give them a value. I use the following values:

Row 1: ` eɪ aɪ aʊ ɔɪ oʊ ɜː ɑr ɛr ɪr ɔr ‿ =
Row 2: ə w ɛ r t ʊ u i o p [ ]
Row 3: ɑ s d f g h j k l ː ˈ
Row 4: z ɝ ʧ v b n m ˌ . /
Row 5: (space)

Note: Do not forget to add a space in the space bar!

Save your work with File> Save. The layout looks like this now:

I do not really care about the keyboard on the right, but if you want to be complete, you can fill it with values ​​like this:

Add more values ​​using modifier keys

There are still more Unicode values ​​I want to add, but the keyboard is already full. The primary way to add more value is to use modification keys. These include Shift, Option, Command, Control and Caps Lock. Use Shift and Option as your first choice, since Command can be used for various shortcuts on your computer.

For the IPA keyboard I make, I will be able to get all the characters I need just by using Shift. However, you can use Option or Shift + Option to get even more ways to enter characters if you need so many.

Print Shift now. You will notice that the Shift buttons on the Ukelele layout turn green and all your other key values ​​disappear:

With the Shift key down, double-click an empty key to add a value to it. I add the grade æ to what would be a capital ONE on a standard English QWERTY keyboard.

When the keyboard layout is complete, this will allow me to enter æ by pressing the Shift key in combination with that key.

Repeat for all remaining characters using modifiers

Hold down Shift and double-click on empty keys, add all the remaining characters you need.

These are the characters I still need to add:

Row 2: ʍ e ɾ θ ʊ ɪ ɔ
Row 3: æ ʃ ð ʰ ɫ
Row 4: ʒ ɚ ʤ ʌ ŋ ʔ

After filling them out, the keyboard with the Shift modifier looks like this:

There are a number of empty keys that have nothing, but that’s OK for me since they’s just shift modification keys.

Save your work again with File> Save.

There are a few steps you need to take to install your keyboard.

Open organizer

In Ukelele go to File> Install> Show Organizer. You should see the keyboard in the left column.

Write click on ipa keyboard element and select Install for current user:

You will receive the following warning. Select Close.

As the warning states, you should not edit the file after installing it. Installation for current user moved ipa.keylayout to the hidden folder Library/Keyboard Layouts in the home directory. You can see hidden folders and files in the Finder by pressing Command+Shift+..

Log out and log in

As recommended by Ukelele, log off your current Mac user session and then log in again. Alternatively, you can restart your computer.

Add the keyboard as an input source

As you saw at the beginning of this article, go to System Preferences> Keyboard> Input Sources. Then click + plus button to add another.

Scroll down and select Others from the list on the left. Then select IPA the keyboard to the right. Finally press add button.

Note: If you want to associate the keyboard with a specific language, you need to create a bundle instead of a single key release file.

Select keyboard

As long as you have the input source displayed on the toolbar, you can change the keyboard layout by selecting the icon. Select IPA from the list:

naʊ ju kæn raɪt wɪθ jɝ nu kibɔrd!

You will probably find that you want to make some changes after you finish the keyboard. For example, in the last line of the section above, I had to change the keyboard to get into !. It would be nice to add some punctuation to the keyboard.

Uninstall the current keyboard layout

Open Ukelele and go to View> View Organizer.

Then right-click ipa and select Uninstall or just drag it to Not installed column.

Edit the keyboard layout

Since the layout is now uninstalled, it is safe to edit. You can open the file by going to File> Recently opened and choose ipa.keylayout.

Make the changes and save the file.

Reinstall the layout

In Ukelele go to View> View Organizer go again ipa back to Installed for current user column.

Select Close when prompted.

Log out and log in

Log out of your Mac user, then log in again. The changes should have taken effect. If not, try restarting your computer.

Get help

You can learn much more by reading the documentation. In Ukelele go to Help> Weekly Manual (PDF). Also check out the instructions in Documentation the folder in the dmg image you received when you downloaded Ukelele.

Starting from an existing setup

In this article, you created a layout from scratch, but an easier way would be to start with a similar layout and just edit it. An easy way to do that is to go to File> New from current input source. There are also many layouts in Resources the folder that came with the Ukelele download. See the documentation for instructions.

More advanced layouts

In addition to modification keys, you can also set up dead keys to give you even more options for input. You can turn almost any key into a dead key. A dead key is like a modification key, but when you press it, nothing happens until you press another key. For example, you can make ` key add an accent to which key comes next.

Share your layout with other people

Anyone can use your layout if they just copy it to Library/Keyboard Layouts folder to the home folder. For less technical users, Ukelele can also create a dmg file that will help people install the setup.

Source link