Keyboard layouts for Sanskrit

This document explains how to set up your keyboard to type in Sanskrit, either using the Dēvanāgarī script (or whatever Indic script you prefer) or in IAST/ISO-15919.

Note that there are very good reasons to ensure that, when you type diacritics, the resulting characters are the canonical Unicode representations of the desired character. For example, I type the character ā by hitting a key for a macron and then hitting the letter a on my keyboard, and thus I input the character in two steps. But the result is a single Unicode character, U+0101. Unicode defines a set of equivalences between uncomposed and composed characters, such that it is possible to convert between the composed characters (like U+0101) and the uncomposed characters (like U+0061 and U+0304) and vice versa. Even if it looks like the correct character on your screen, this is no guarantee that what you see in front of you is the “normal” (in the sense of normalized or normalizable) character.

Linux (Ubuntu 16.04 LTS)

Choosing a keyboard layout

You can change your keyboard layout by selecting KeyboardInput Sources, which brings up the Region and Language dialogue:

Click + to add a layout. For Dēvanāgarī, I recommend one of the Hindi layouts. The KaGaPa Phonetic layout is probably the easiest to learn, since the values are more or less the same as on the English keyboard.

Here is the layout chart for Hindi (KaGaPa Phonetic):

For typing in transliteration, one ready-made option are the “international” keyboard layouts, which include “dead keys” for diacritics. A dead key is a key combination that doesn’t produce any output when it is pressed, but which tells the computer that the following keystroke should be combined with a certain diacritical mark. One recommended option is English (US, international with dead keys):

With this layout, you can type ś by hitting the key combination for a combining acute, which is ' and then hitting the key s. The “dead key” for an underdot is AltGr + Shift + -, and the “dead key” for a macron is AltGr + Shift + 3. AltGr is usually the right-alt key, although I have it mapped to the Windows key on my laptop. See this page for more on the International keyboard layout and dead keys.

If you find the use of these dead key combinations too tiresome, as I do, you can add your own keyboard layout.

You can change the command to switch between keyboard layouts in Options under Region and Language.

Adding your own keyboard layouts

The X11 window manager takes care of keyboard layouts. These are defined in /usr/share/X11/xkb/symbols/ in Ubuntu. Each region has a file which defines layouts associated with that region. For Sanskrit, these layouts are located in in (for “India”). I have added a layout to this file which is contained in this gist, although you should change it to suit your preferences.

Once you have added your keyboard layout, and given it a suitable name (I have called mine san-trans/usr/share/X11/rules/evdev.xml. I have added the following <variant> to my files:

	
<variant>
  <configItem>
    <name>san-trans</name>
    <shortDescription>sa</shortDescription>
    <description>Sanskrit (Transliteration)</description>
    <languageList>
      <iso639Id>san</iso639Id>
    </languageList>
  </configItem>
</variant>
	
      

To refresh the cache of keyboard layouts, type:

	sudo dpkg-reconfigure xkb-data
      

Now you should be able to select your keyboard layout from the list under KeyboardInput Sources.

Links