UNIX provides a database of Terminal Definitions {the terminfo database} used to map key sequences, to a standardised set of names. It is also used in the reverse direction to map desired actions to sequences of control or escape codes.

One of the snags with DEC terminals or Terminal emulators is that the original VT52 terminal had only four programmable/function keys located above the numeric key pad and labled PF1, PF2, PF3, and PF4.

The ASCII keyboard has 16, and the standard ANSI keyboard 12.

When the vt100 was launched DEC added a extra row of keys labled F1...F12 The PF1....PF4 keys were retained for compatability with software writen for the VT52. Of the new keys the first 5 were reserved for terminal control functions and were not available for use with applications.

Terminals or terminal emulation programs that "Emulate" a DEC vt100 or the later vt220, family of terminals thus have to have made a desision on keyboard mapping. This depends on the physical keyboard layout ANSI, ASCII, or DEC.

Where ANSI or ASCII key boards are conserned the most common mapping is for F1...F4 to send the sequences associated with PF1...PF4, and F6.... to send the corresponding DEC sequence, as F5 did not exist an unused sequence in normaly sent in this case.

The codes actualy being send by a terminal can be determined by running the command

od -c

and pressing the keys inturn, seperated by a suitable character like space to make it easy to tell where a sequence starts and ends.

F5 mappings
 Terminal  Value
 falco5220vt  033 [ 3 4 ~
 icl320  033 [ 2 9 ~
 tek7025  033 [ 1 6 ~

The values stored in the terminfo database for the curent terminal can be obtained with the following command.

tput kf1|od -c

Drawing out a table of the resulting values is a big help to solving terminal setup problems.

Example Keyboard Mapping
 Keyboard Lable  String sent  terminfo name  exception code from vdttest  roadrunner function
 PF1  033 O P \n  kf1  1  f1
 PF2  033 O Q \n  kf2  2  f2
 PF3  033 O R \n  kf3  3  f3
 PF4  033 O S \n  kf4  4  f4
         
 F1        
 F2        
 F3        
 F4        
 F5        
 F6  033 [ 1 7 ~  kf5  5  f5
 F7  033 [ 1 8 ~  kf6  6  f6
 F8  033 [ 1 9 ~  kf7  7  f7
 F9  033 [ 2 0 ~  kf8  8  f8
 F10  033 [ 2 1 ~  kf9  9  f9
 F11  033 [ 2 3 ~      
 F12  033 [ 2 4 ~      
 F13  033 [ 2 5 ~      
 F14  033 [ 2 6 ~      
 F17  033 [ 3 1 ~      
 F18  033 [ 3 2 ~      
 F19  033 [ 3 3 ~      
 F20  033 [ 3 4 ~      
         
 DO  033 [ 2 9 ~  kf10  10  f10