Custom Keyboard Layout for Arabic, Persian, and Turkish (Mac)

In 2015, when I was still using Linux, I posted my template for a custom keyboard layout that gave easy access to some of the special characters that scholars working in Arabic, Persian, and Turkish tend to require. Not long after, however, I transitioned (back) to Mac, and found myself needing to create a similar custom keyboard. After some experimentation, I’ve settled on a layout I like; here it is for you to use or modify as you like.

The Layout

This layout is called IJMESv3 (the third version of my IJMES-friendly layout), and it is based on the ABC - Extended layout that comes with MacOS. The basic layout is the same as a standard Mac keyboard, but when you hold the option key, this is what you’ll have access to:

The keys outlined in orange are modifier keys, meaning that you first hit the diacritic you want, then the key to apply it to. For example, option+v is the modifier key for the caron / háček, so typing option+v, s will give you š, and so on for č, ž, etc. Similarly, option+w adds (or removes) an overdot, so you can use it to type glyphs like ż, , or ı. The other modifiers are pretty self-evident—option+e for acute (é, etc), option+y for umlaut (ü, etc.), and so on—though if you want to see some very unusual symbols, type option+shift+semicolon and let ’er rip! You can watch your options unfold in real time by clicking on the keyboard icon in the menu bar and selecting Show Keyboard Viewer (you might have to enable this in your Keyboard system preferences). Some features of particular interest for the field:

  • The common macrons Ā, Ī, and Ū are immediately available by pressing the option key (Ē and Ō can be accessed with option+j)
  • The common underdotted glyphs Ṣ, Ṭ, Ḍ, Ẓ, and Ḥ are accessed with the option key (less common glyphs, such as Ḳ, can be typed with option+x)
  • Turkish Ğ is immediately accessible as option+g
  • The signs for hamza (ʾ) and ʿayn (ʿ) are option+2 and option+3, respectively (Arabeezi style)
  • Quotation marks—double, single, and guillemet—are found at [, ], and \ respectively; hit option to open and option+shift to close
  • I have over-lines, through-lines, and under-lines mapped to option+j, option+k, and option+l respectively (note that the underlined s̱, commonly used to transliterate Persian ث, is not an actual Unicode character, so you have to type s and then the Combining Macron Below character: s, option+shift+l)
  • For those interested in metrics, you can find the characters ⏑ , ⏒ , and ⏔ on the numbers 6 and 7; use option+- for the long syllable (–)

Installation

  1. Download IJMESv3.bundle.zip and unzip it
  2. Go to the Finder, click on Go in the Menu Bar, select Go to Folder…, and type /Library/Keyboard Layouts/
  3. Drag and drop IJMESv3.bundle into that folder
  4. Logout or restart
  5. Open System Preferences… in the  menu, select Keyboard, click on Input Sources, hit +, and you should be able to find IJMESv3 among the English layouts

You’ll know you’ve got the right one if you see a bright red-and-yellow square with the Derafsh Kaviani on it (I wanted something that looked good in both Light and Dark modes).

That’s all you need to do on your end! If you’re interested in knowing more about how I made this file, or how you might modify it, read on.

Creation, Manipulation, and Other Links

I used the useful program Ukelele to create this layout. If you want to make any tweaks to this file, download Ukelele and open IJMESv3.bundle with it. There, you’ll be able to change output, terminals, modifier keys, names, icons, you name it. You can also create your own layout by selecting the input source that most closely matches your ideal, then going to Ukelele and selecting New From Current Input Source from the File menu. This will create a copy of the layout that you can fiddle with, and when you are done, drop it into your Keyboard Layouts folder as detailed above and you should be able to type with it!

Another helpful resource to consult is the website Computing in ME Languages, hosted at the University of Chicago Library. It’s a little old, but as far as I know its Alt-Latin keyboard layout still works on modern machines.

Hope this helps you all!

Arabic and Persian diacritics for Ubuntu keyboard

I’ll inaugurate my new site with a blast from the past. It may be useful for someone out there.

Some years ago, I started playing with Linux, specifically Ubuntu, and one thing I had to work at to get running was a good layout for Arabic and Persian transliteration. Some of the default international keyboards that come bundled with most Linux distribution carried most of the diacritics I need, but usually they were tucked away in awkward places and none of them included ayn and hamza, so I had to build my own layout. As far as I know, there are no easy GUI programs out there to create a custom layout; you just have to go in the old-fashioned way and edit the text file. Fortunately, it’s pretty simple. Each line begins with a code that defines the key; typically, this will be A (for alphanumeric), A-E (rows 1 to 5, bottom to top) 1-12 (key position in the row, going left to right). After the key is defined, you can offer up to four values, which will correspond with what the key will produce by itself, with Shift, with AltGr (usually the right Alt key), and Shift+AltGr respectively. So, for example, let us consider the following line:

key <AD07> { [ u, U, uacute, Uacute ] };

So from the code, we know that this key on the alphanumeric keyboard, fourth row from bottom, seventh from the left. If you found the letter “U”, good job. Now we see that by itself, it produces “u”, with Shift “U”, with AltGr “ú”, and with Shift+AltGr “Ú”. You can substitute these names with their Unicode equivalents; for example, the Unicode ID for “Ú” is U00DA, so you could erase “Uacute” and replace it with “U00DA” and get the same character. I did this when inserting my characters, simply because I didn’t know all their names and you can be absolutely precise when picking your character.

Installation: In Ubuntu, and I assume most Debian-based flavors of Linux (if not more), the keyboard layout files are located in /usr/share/X11/xkb/symbols. If you don’t find it there, look it up for your system and it should be fairly easy to locate. Now the first thing to do is decide which keyboard you want to modify. I chose the US “alternative international” keyboard, since ‘alternative’ is a good word to describe what we’re doing. First thing’s first, you’ll want to backup your keyboard, so in case you run into any problems, you can restore the original without any hassle. All this will have to be done through the terminal using the sudo command. Here are the steps you’ll go through:

  1. Open a terminal
  2. Type cd /usr/share/X11/xkb/symbols (or the appropriate directory)
  3. Type sudo cp us us_backup (this makes your backup)
  4. Type sudo gedit us (or choose your favorite text editor)
  5. Once the document is opened, search for “Alternative International” group (it was the third one down, for me)
  6. Highlight the text from partial alphanumeric_keys down to };
  7. Delete the text and copy the layout below in its place
  8. Save the document, quit, and log out
  9. When you log back in, go to the “Keyboard Layout” preference, hit the + button, and add English (US, alternative international) to your list of layouts
  10. If you run into problems, you can always sudo rm us and then restore the original by typing sudo cp us_backup us

Here is the code to copy over:

partial alphanumeric_keys
xkb_symbols "alt-intl" {

name[Group1]= "English (US, alternative international)";

include "us"

key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
key <AE01> { [ 1, exclam, exclamdown, questiondown ] };
key <AE02> { [ 2, at, U02BE ] };
key <AE03> { [ 3, numbersign, U02BF ] };
key <AE04> { [ 4, dollar, sterling, EuroSign ] };
key <AE05> { [ 5, percent, onehalf, onequarter ] };
key <AE06> { [ 6, asciicircum, U00A7, dead_circumflex ] };
key <AE07> { [ 7, ampersand, U00B6, dead_hook ] };
key <AE08> { [ 8, asterisk, U2022, U00B0 ] };
key <AE09> { [ 9, parenleft, dead_breve ] };
key <AE10> { [ 0, parenright, dead_abovering ] };
key <AE11> { [ minus, underscore, U2013, U2014 ] };
key <AE12> { [ equal, plus, multiply, U00F7 ] };

key <AD01> { [ q, Q, dead_belowdot ] };
key <AD02> { [ w, W, U02B7, U1D5B ] };
key <AD03> { [ e, E, U0113, U0112 ] };
key <AD04> { [ r, R, dead_acute, dead_grave ] };
key <AD05> { [ t, T, U1E6D, U1E6C ] };
key <AD06> { [ y, Y, U1E6F, U1E6E ] };
key <AD07> { [ u, U, U016B, U016A ] };
key <AD08> { [ i, I, U012B, U012A ] };
key <AD09> { [ o, O, U014D, U014C ] };
key <AD10> { [ p, P, leftsinglequotemark, rightsinglequotemark ] };
key <AD11> { [ bracketleft, braceleft, leftdoublequotemark, guillemotleft ] };
key <AD12> { [ bracketright, braceright, rightdoublequotemark, guillemotright ] };
key <BKSL> { [ backslash, bar, notsign, brokenbar ] };

key <AC01> { [ a, A, U0101, U0100 ] };
key <AC02> { [ s, S, U1E63, U1E62 ] };
key <AC03> { [ d, D, U1E0D, U1E0C ] };
key <AC04> { [ f, F, U1E0F, U1E0E ] };
key <AC05> { [ g, G, U0121, U0120 ] };
key <AC06> { [ h, H, U1E25, U1E24 ] };
key <AC08> { [ k, K, U1E35, U1E34 ] };
key <AC09> { [ l, L, U1E2B, U1E2A ] };
key <AC10> { [ semicolon, colon, dead_diaeresis ] };
key <AC11> { [ apostrophe, quotedbl, dead_acute ] };

key <AB01> { [ z, Z, U1E93, U1E92 ] };
key <AB02> { [ x, X, U1E95, U1E94 ] };
key <AB03> { [ c, C, U010D, U010C ] };
key <AB04> { [ v, V, U0161, U0160 ] };
key <AB06> { [ n, N, U23D1, U23D2 ] };
key <AB07> { [ m, M, U2014, U23D4 ] };
key <AB08> { [ comma, less, dead_cedilla, dead_circumflex ] };
key <AB09> { [ period, greater, dead_abovedot, dead_caron ] };
key <AB10> { [ slash, question, U0331, U0304 ] };

include "level3(ralt_switch)"
};

// Keyboard layout by Cameron Cross for Arabists and Persianists.
// Dead characters (use AltGr):
// ~ = grave and tilde / 3 = macron / 6 = circumflex / 7 = hook / 9 = breve / 0 = abovering
// ; = diaresis / ' = accent / , = cedilla / . = dot above / ? = combining macrons below and above
// q = dot below / r = grave and acute / < = circumflex / > = caron
// Special characters (activated with AltGr):
// All vowels have macrons; s t d and z all come with dots below
// 1 = ¡ ¿ / 4 = currencies / 5 = percentages / - = en/em dash / = math characters
// 2 and 3 = ʾ and ʿ (Arabeezi style)
// y = ṯ / f = ḏ / x = ẕ / g = ġ / c = č / v = š /
// k and l = ḵ and ḫ (two alternatives for transliterating "kh")
// w = ʷ and ᵛ (for Persian خو)
// p [ ] = quotes (‘’«»“”)
// n and m = metrical signs ⏑ ⏒ —⏔

As you can see from the comments section, this keyboard is very specifically tailored to my needs. I borrowed elements I like from the US International, UK, and Macintosh layouts, plus some of my own ideas. I write a lot about poetry, so I designated “n” and “m” for metrical units. I also prefer to avoid digraphs in my transliteration, so I have all these special characters for “th”, “kh”, “sh”, “ch”, and “gh” around the center of the keyboard (see comments). The Arabeezi system of 2 for ق (which is often pronounced as hamza, hence ʾ) and 3 for ع is pretty intuitive for me, so I kept that, and I love the Mac’s handling of – for en and em dashes—which I use all the time—so those are there. I will point out that this keyboard is not ideal for Turkish, although you can use AltGr+9+g for ğ and AltGr+.+i for your dotless ı. On the other hand, once the layout is successfully installed, you can go back and tweak the file with your own Unicode characters as you like. Save your changes in a separate text file, so that if you ever upgrade your system, you can just copy and paste it into the document like you did before. Piece o’ cake.

For more information, check out the following sites. I especially liked the one by the fellow medievalist who works on Anglo-Saxon literature.