Getting the Key Label for a Keycode

Because of the limited number of function and other special keys on some terminal keyboards, the user may be required to press a series of keys to create an escape sequence to generate a keycode, as defined in vvtermcap. During initialization, a pointer to a string holding the escape sequence that generates the keycode is stored in the key definition table. This table is built from the entries in vvtermcap that define the keys.

For your convenience, a function is provided to return the string containing the key label to generate a particular keycode. You can use this string to generate help text and other messages for the user.

The function that returns the key label for a keycode is as follows:

UCHAR *key_getlabel(keycode)

int keycode;    /* Keycode to get key label for        */

key_getlabel() searches the global key definition table for the specified keycode and returns the key label string. If the keycode is not found, NULLP is returned.

For example, if the program is running on a VT100 terminal and you call:

UCHAR *stp;

stp = key_getlabel(KEY_PGUP);

key_getlabel() would return a pointer to the string "CTRL-U". If the program is running on a Wyse-50 terminal, key_getlabel() would return a pointer to the string "Page Prev". You can use the returned strings to build help messages that are specific to the current terminal environment. See the tutorial program keylabel.c for an example of how to use key_getlabel() and the string translation facility to do this.


Home Contents Previous Next