NRSI: Computers & Writing Systems
Perl script to create Mac OS X keyboard layouts
The Perl script KeyLayoutMaker.pl is intended to provide a quick way to create at least a first draft of an XML keyboard layout file (.keylayout) for Mac OS X version 10.2 or later. Further adjustment, either using an editor such as Ukelele or by hand-editing the resulting XML file, may often be helpful.
This script is not a general-purpose tool for creating all types of keyboard layouts; it is designed specifically for situations where many multi-key sequences are required to generate single Unicode characters. This is one way in which syllabic scripts can be keyboarded: the keystrokes can be based on a simple romanization, such as that used in the Unicode character name. The keyboard layout created by this script will use dead key states (multiple levels, if necessary) to implement such layouts.
Updated: June 1, 2006
Release 4 of the KeyLayoutMaker.pl script includes minor bug-fixes, and allows keystroke files to include comments: any indented lines will be ignored, and '#' may be used to introduce comments after the Unicode output on any line.
KeyLayoutMaker is a Perl script intended to be run from the Mac OS X command line (i.e., within a Terminal window or similar shell):
perl KeyLayoutMaker.pl -i layoutID -n layoutName -k keystrokeFile
All three parameters are required; if any are missing, the script will simply print a usage message and terminate.
The XML keylayout definition is written to standard output (so it is normal to use redirection to send it to a file).
Thus, a typical command line might be:
perl KeyLayoutMaker.pl -i -200 -n "Cree Syllabics" -k Cree.keystrokes > Cree.keylayout
where the Cree.keystrokes file begins:
a 140a aa 140b aai 1402 ai 141c an 142e c 14a1 ca 1490
The resulting .keylayout file can be installed in or a personal folder. It is necessary to log out of OS X and log in again before it will be available; then use to add the new layout to the Input menu list.
The KeyLayoutMaker distribution includes several example "keystroke files" based either on Unicode character names or on key sequences used in older legacy systems for particular languages.
For other resources related to Mac OS X keyboard layouts (tools, documentation, and available layouts), see the Input Resources page.
The KeyLayoutMaker.pl script and associated sample files and documentation are written by Jonathan Kew and copyright ©2004-2006 SIL International. They are made available with no warranty or support under SIL's standard freeware license.