KEY(n)¶
Function¶
KEY(n) activates and terminates trapping of soft keys.
Syntax¶
n is a numeric expression in the range 1 to 8 to reference the soft key.
Example¶
10 ON KEY (1) GOSUB 1000
20 KEY (1) ON
.
.
.
900 END 'FINISH OF MAIN ROUTINE
1000 REM SOFT KEY (1) TRAP ROUTINE
1990 RETURN
.
.
.
Remarks¶
The KEY(n) statement is used for trapping either soft key entries or cursor entries during program execution. It is intiialised with the ON KEY statement.
KEY (n) ON, when executed, activates trapping of the keys. A GOSUB is automatically executed when a key is pressed to the line number specified in the ON KEY statement.
The display of the soft key function is not altered with this statement.
If the same key is pressed again while the subroutine is being processed, then the interrupt is stored until the program returns from the interrupt routine when the GOSUB will be executed again.
If a different key is pressed while one interrupt routine is being processed, then another GOSUB is immediately executed. Different key trapping routines may be nested, but each individual routine cannot be re-entered.
- KEY (n) OFF
The trapping routine is deactivated, and the key press is ignored.
- KEY (n) STOP
Immediate execution of the trapping routine does not take place, but the key is remembered and left pending until a KEY (n) ON statement is encountered.