Special variables -- $KEY


Introduced in the 1995 ANSI M[UMPS] language standard.

The value of $KEY is the string that terminated the most recent input.

After a command like READ X#20, the value of $KEY is most likely to be equal to the empty string.
After a command like READ X, the value of $KEY will usually be equal to $CHAR(13) (the enter- key). However, when input was terminated by typing a function key, the value of $KEY will be equal to the string of characters that is transmitted by that function key. The most common function keys on the VT-100 and compatible terminals are:

Key Code sequence
Up arrow $CHAR(27,91,65)
Down arrow $CHAR(27,91,66)
Right arrow $CHAR(27,81,67)
Left arrow $CHAR(27,91,68)
PF1 $CHAR(27,80)
PF2 $CHAR(27,81)
PF3 $CHAR(27,82)
PF4 $CHAR(27,83)

In addition, the VT-200 terminals (and the more modern versions of that family of terminals) also offer:

Key Code sequence
Find $CHAR(27,91)_"1~"
Insert $CHAR(27,91)_"2~"
Remove $CHAR(27,91)_"3~"
Select $CHAR(27,91)_"4~"
Previous page $CHAR(27,91)_"5~"
Next page $CHAR(27,91)_"6~"
F7 $CHAR(27,91)_"18~"
F8 $CHAR(27,91)_"19~"
F9 $CHAR(27,91)_"20~"
F10 $CHAR(27,91)_"21~"
F11 $CHAR(27,91)_"23~"
F12 $CHAR(27,91)_"24~"
F13 $CHAR(27,91)_"25~"
F14 $CHAR(27,91)_"26~"
Help $CHAR(27,91)_"28~"
Do $CHAR(27,91)_"29~"
F17 $CHAR(27,91)_"31~"
F18 $CHAR(27,91)_"32~"
F19 $CHAR(27,91)_"33~"
F20 $CHAR(27,91)_"34~"

Approved for addition in a future ANSI M[UMPS] Language Standard.

The initial value of $KEY is implementation-dependent. However, if the initial value of $IO is the empty string, then the initial value of $KEY is also the empty string.

This document is © Ed de Moel, 1995-2005.
It is part of a book by Ed de Moel that is published under the title "M[UMPS] by Example" (ISBN 0-918118-42-5).
Printed copies of the book are no longer available.

This document describes the various special variables that are defined in the M[UMPS] language standard (ANSI X11.1, ISO 11756).

The information in this document is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.

In this document, information is included that will appear in future standards.
The MDC cannot guarantee that these 'next' standards will indeed appear.