The KEY command may be used to define an equivalence string for any key on the keyboard. For example:
KEY PF1 PROCS#
defines the PF1 key so as to issue the PROCS command. The # character is
used to indicate a Return character in the equivalence string.
The name of a main keyboard key may be specified as a single character or as an integer representing the ASCII code for the key. Keypad of Function keys are specified by names as follows:
Keypad keys -- PF1, PF2, PF3, PF4, KP0, KP1, KP2, KP3, KP4, KP5, KP6, KP7, KP8, KP9, ENTER, MINUS, COMMA, PERIOD.
Function Keys (VT200) -- F6, F7, F8, F9, F10, F11, F12, F13, F14, HELP, DO, F17, F18, F19, F20.
Editing Keypad (VT200) -- FIND, INSERT_HERE, REMOVE, SELECT, PREV_SCREEN, NEXT_SCREEN.
Cursor Keys -- UP, DOWN, LEFT, RIGHT.
KEYTRAP and INKEY allow an ICL procedure to test for keyboard input during its execution, without having to issue an INPUT command and thus wait for input to complete. KEYTRAP specifies the name of a key to be trapped. INKEY is an integer function which returns zero if no key has been pressed or the key value if a key has been pressed since the last call. The key value is the ASCII value for ASCII characters, or a number between 256 and 511 for keypad and function keys. The KEYVAL function may be used to obtain the value from the key name.
{ Trap ENTER and LEFT and RIGHT arrow keys }
KEYTRAP ENTER
KEYTRAP LEFT
KEYTRAP RIGHT
LOOP
K = INKEY()
IF K = KEYVAL('ENTER') THEN
.
ELSE IF K = KEYVAL('LEFT') THEN
.
ELSE IF K = KEYVAL('RIGHT') THEN
.
ELSE
.
ENDIF
END LOOP
The command
KEYOFF keynamemay be used to turn off trapping of a key.
ICL The Interactive Command Language for ADAM