ON KEY target
Setup an interrupt which will call ‘target’ line number, label or user defined subroutine whenever there is one or more characters waiting in the input buffer. The characters can come from the keyboard, USB or serial console.
Return from an interrupt is via the IRETURN statement except where a user defined subroutine is used (in that case END SUB or EXIT SUB is used). Note that subroutine parameters cannot be used.
Note that all characters waiting in the input buffer should be read in the interrupt routine otherwise another interrupt will be automatically generated as soon as the program returns from the interrupt.
To disable this interrupt, use numeric zero for the target, ie: ON KEY 0
See also:
INKEY$
INPUT (from keyboard)
KEYDOWN
LINE INPUT (from keyboard)
Leave a Reply