

Keyboard files define the relationships between the character sequences or key
codes sent from the keyboard and the edit functions for the nu/TPU interface.
nu/TPU works on various platforms and operating systems. The outcome of all
that versatility is that there is a wide variety of keyboards nu/TPU has to work
with. The keyboard files that have been predefined are located in the nu_tpu/dev directory. The files contained in the dev directory will differ for DOS and
UNIX systems. The UNIX keyboard drivers for the character cell and Motif versions
of nu/TPU also differ in the type of information captured for keyname
assignments. The character cell keyboard files use escape sequences to assign keynames
for the UNIX environment. The DOS and MS Windows keyboard drivers use the same
information and format. ASCII key code numbers are used for the X and MS
Windows keyboard files. Examples of each are provided in Appendix D. If none of the
prebuilt keyboards provide an exact match to your keyboard, new keyboard files
can quickly be created or existing ones can be modified.
nu/TPU automatically uses the ASCII characters generated by the typewriter
section of the keyboard. Additionally, keyboard files can define up to 40 function
keys, 18 numeric keypad keys, 6 editing keys, and the 4 cursor keys: UP, DOWN,
LEFT, and RIGHT. Control keys are considered part of the standard typewriter
section.
To provide the mapping from the keyboard character sequence to an edit
function, nu/TPU defines a set of keynames for internal use. For a list of the nu/TPU
keynames, see Appendix B or issue the si SHOW KEYS command.
The process by which nu/TPU interprets a key press to perform an edit function
is as follows
1. During the nu/TPU initialization process, the keyboard file is read.
2. A key press occurs.
3. An escape sequence or key code is passed to nu/TPU.
4. nu/TPU searches for the matching escape sequence or key code as defined by the
active keyboard driver. If no match is found, the key characters are handled
as undefined keys, usually resulting as input to the current edit buffer.
5. When the match is successful, the associated keyname is used and its edit
function is performed.
Three of nu/TPUs standard keyboard files are included in Appendix D. The
first, vt200, uses escape sequences for UNIX systems. The next, enhanced.edt, uses
key codes for MS Windows and DOS systems. The third, dec_risc.x, is a keyboard
driver for the X Windows environment. It uses X key code values.
Most, if not all, of the keynames can be determined by matching keynames to
the keypad diagram in the keyboard file. For example, KP4 signifies the 4" key
on the numeric keypad. What about the text :0x4b" that comes after the keyname
KP4 in the enhanced.edt file? The colon (:) is what separates the nu/TPU
keyname and its associated key code value. The 0xnnnn is the scan code for each
specific key. On systems that use escape sequences, the escape character is
indicated by the \E characters as seen in the vt200 file. For X and MS Windows
keyboard drivers, the key code follows the colon.
Determining Escape Key Codes for UNIX
If you do not have any hardware documentation providing key codes for your
keyboard, use one of the following methods to obtain the information to build or
modify a nu/TPU keyboard file.
nu/TPU UNIX keyboard drivers need the escape sequence for each key you wish to
define that is not located on the typewriter section of the keyboard. Use the
standard UNIX command cat and redirect the output to a file. The following
command will capture all character output generated from key presses and include
the text into the file keys until CTRL-D is pressed.
cat > keys
Using the following method to capture UNIX escape sequence values will
simplify the formatting process to convert the output file to the nu/TPU keyboard
syntax. For each key that you wish to capture its escape sequence, first enter a
descriptor name followed by a colon, then press the actual key for which you want
the escape sequence, followed by another colon and the return key to start a
new line. For example, if you want the value of the up arrow key, the sequence
would be as follows:
upkey:UpArrow :Return
The above key sequence on a vt200 terminal would generate:
upkey:^[[A:
Two steps are required to translate the output into a key definition for a
nu/TPU keyboard file. First, the keyname you provided during the cat process must
be replaced with a valid nu/TPU keyname. A list of nu/TPU keynames can be found
in Appendix B. Second, the characters generated for escape ^[ must be
converted to \E for the keyboard driver. The remaining portion of the line, the :
and the [A, are left unchanged. The result of converting the original output
line upkey:^[[A and assigning it to the nu/TPU keyname UP would be:
UP:\E[A:
Determining X Windows Key Codes
nu/TPU keyboard files for the X environment only have one difference from
their character cell counterparts. The nu/TPU keynames are matched to X key code
numbers instead of escape sequences. For example, compare the cursor key
assignments for a DEC OSF/1 Motif system and a vt200 character cell definition.
DEC UNIX Motif vt200
UP:170: UP:\E[A:
LEFT:167: LEFT:\E[D:
DOWN:169: DOWN:\E[B:
RIGHT:168: RIGHT:E[C:
The process for building X or MS Windows keyboard drivers is the same as the
character cell environment.
An alternative method to obtain key codes for the X Windows environment is
using the xev program supplied with nu/TPU or use the xev program supplied with
your system, normally located in the /usr/bin/X11 library. Once the xev program
is started, press the keys for which you wish to obtain their key codes. Record
the key code values displayed in the main xev window and update the nu/TPU
keyboard driver. The following text is sample output from xev after pressing the up
and left cursor keys.
KeyPress event, serial 15, synthetic NO, window 0x900001, root
0x8006b, subw 0x0, time 2677034158, (541,311), root:(745,481),
state 0x0, keycode 170 (keysym 0xff52, Up), same_screen YES,
XLookupString gives 0 characters:
KeyRelease event, serial 15, synthetic NO, window 0x900001, root
0x8006b, subw 0x0, time 2677034235, (541,311), root:(745,481),
state 0x0, keycode 170 (keysym 0xff52, Up), same_screen YES,
XLookupString gives 0 characters:
KeyPress event, serial 15, synthetic NO, window 0x900001, root
0x8006b, subw 0x0, time 2676861037, (294,366), root:(498,536),
state 0x0, keycode 167 (keysym 0xff51, Left), same_screen YES,
XLookupString gives 0 characters:
KeyRelease event, serial 15, synthetic NO, window 0x900001, root
0x8006b, subw 0x0, time 2676861180, (294,366), root:(498,536),
state 0x0, keycode 16 (keysym 0xff51, Left), same_screen YES,
XLookupString gives 0 characters:
nu/TPU contains predefined X keyboard drivers in the nu_tpu/dev directory. The
X Windows drivers end in .x.
Keyboard File