Specifications

Chapter 14. Statement Reference
260
Syntax:
ON KEY (keynumber) GOSUB label
Parameter:
keynumber
A numeric expression which returns a value from 1 to 31, 33 to 38, and 501
to 550.
Description:
According to label, ON KEY...GOSUB specifies the first line of an event-handling
routine to be invoked if a function key specified by keynumber is pressed. (Refer
to Appendix E, "Key Number Assignment on the Keyboard.")
ON KEY...GOSUB specifies only the location of an event-handling routine but does
not enable keystroke trapping. It is KEY ON statement that enables keystroke
trapping. (Refer to KEY ON and KEY OFF.)
Specification of zero (0) to label disables keystroke trapping.
If a keystroke trap occurs, the Interpreter automatically executes KEY OFF state-
ment for the pressed function key before passing control to an event-handling rou-
tine specified by label in ON KEY...GOSUB statement. This prevents a same
event-handling routine from becoming invoked again by pressing a same function
key during execution of the routine until the current event-handling routine is com-
pleted by issuing a RETURN statement.
When control returns from the event-handling routine by a RETURN statement,
the Interpreter automatically executes KEY ON statement.
If it is not necessary to resume keystroke trapping, you describe a KEY OFF
statement in the event-handling routine.
If you issue more than one ON KEY...GOSUB statement specifying a same key-
number
, the last statement takes effect.
You can nest GOSUB statements to a maximum of 10 levels.
I/O statement
ON KEY...GOSUB
Specifies an event-handling routine for keystroke interrupt.