KeyMap -  User-defined keyboard mapping

by Alan Wrigley

Keymap is an application that enables you to remap the characters on your keyboard to any ASCII codes you like. Not only this, but you can specify which applications use the remapped keys, and which continue to accept standard keyboard input.

This facility has many uses. For example, you might want to use a font in a language which has characters for which there is no alphabet available on the computer - Japanese, say. You could then arrange for certain keys to produce certain characters to suit your own requirements. Or you might want to make regular use of some of the symbols which are normally only available by using the Alt-keypad combination; for example, if you use the Yen symbol a lot, but rarely use the Dollar, you could map the dollar key to the yen symbol. You can map any or all of the characters between ASCII codes 32 and 126 - i.e. the standard codes available from a normal keyboard - to any ASCII code from 0-255.

KeyMap can be run in the normal way from the RISC User menu system or by double-clicking on its icon in a directory viewer. An icon is installed on the icon bar. Clicking Select on the icon bar icon opens the Tasks window which shows all the application tasks currently running. Alongside each is an option button which allows you to turn remapping on or off for that application. So for example if you want to type a letter in Vietnamese in Impression, then provided you have set the keyboard mapping to suit your Vietnamese characters (as described below), you can turn remapping on for Impression, but leave the keyboard input to all other applications unchanged. As applications are run or quit their names will be added to or removed from KeyMap's Tasks window.

Clicking Adjust over the icon bar icon opens the Definitions window showing which codes are mapped to each keyboard character. Clicking Menu over any of the entries in this window opens a menu with three options. Remap allows you to remap that character by typing its ASCII code into the writable icon and pressing Return or clicking the OK button. The other two options are explained below.

The icon bar menu has four options, of which Info and Quit perform their usual functions. The other two items are Tasks, which toggles the Tasks window open or closed, and Define which performs the same action for the Definitions window.

Altering the default mappings
When the program starts up it looks for a file called Mappings inside the !KeyMap.Resources directory. This contains details of the mappings which will be used whenever remapping is switched on for any task (provided they have not been altered from the Definitions window as described above). You can alter this default file so that your own choice of characters is installed when the program is run, or indeed drag any other text file containing mapping data to the application while it is running.

The Mappings file, and any other file dragged to the application, must be of the correct format. It should be a text file exactly 99 bytes long. The first four bytes contain the characters "KBMP", and the remainder of the file consists of the characters which are to be substituted for the ASCII codes 32 to 126 - i.e. from Space to Tilde inclusive. Thus the mappings file for the standard unaltered Latin1 alphabet would start off like this:
  KBMP !"#$%&'()*+,-./012345
and so on (there is a space after "KBMP" of course!). If the format of the file is incorrect it will be rejected by the application.

You can save the current mappings by clicking Menu over the Definitions window. The Save option leads to a save box allowing you to save the file by dragging in the usual RISC OS manner. The Save as default option simply saves the current mappings in the application's own Mappings file.

KeyMap makes use of the RISC OS Filter Manager, as described in the Wimp Topics article in this month's RISC User magazine. It loads a support module when run, and the commented source code is included with the application. For more details on how it works, see the article in the magazine.

Copyright  Rheingold Enterprises 1996
