Remapping the keyboard

Remapping the keyboard with TERMINFO

Re-mapping the keyboard is perhaps best done by terminal type in the TERMINFO file for that terminal using the map feature. For instance on a vt220 terminal to translate the ISO character 'ö' which sends HEX(F6) to the 7 bit equivalent of HEX(7C) include:

map(\x7C)=	\xF6

in the vt220 section of TERMINFO/src. This mapping is then fixed for all terminals of that terminal type. TERMINFO provides the simplest way of handing terminal differences by terminal.

Remapping the keyboard with $TRAN

Single keys can be translated under program command with the $TRAN /001 statement which defines a 256 element translation table for simple keys. Multi-character sequences are not translated this way. See the $TRAN statement for more information. Because $TRAN ignores multi-character sequences, to translate function keys under program control the $KEYBOARD statement may be used, see below. To remap the 'ö' character of the previous example using $TRAN try

STR($TRAN /001, VAL(HEX(F6))+1, 1) = HEX(7C)

Re-mapping the keyboard with $KEYBOARD

The $KEYBOARD statement can be used to allow a program to control the Kclient keyboard mapping. A utility editkb can be used to map Windows Virtual Key codes to KCML equivalents. The string generated by that utility can be pasted directly into the program.

There is an older usage for $KEYBOARD in DOS KCML which is still supported for compatibility. It used a 576 byte string defining two translation tables, one for simple keys and one for complex keys. The exact definition of a complex key was controlled by the KCML implementation but basically simple keys send single characters and complex keys send multi-character sequences. By setting a bit in a bit map the resulting translated key can be labelled as a function key. A DOS utility KYBEDIT.EXE is shipped with DOS versions of KCML4 to edit these tables and the -b switch to tik could generate them from TERMINFO definitions.