HTBasic Help
×
Menu
Index

ON KBD

Defines an event branch for when a key is pressed.
 
 ON KBD [ALL] [,priority] action
 
Usage:
ON KBD GOTO 2000
ON KBD,Order GOSUB First
ON KBD ALL RECOVER 500
ON KBD ALL,3 CALL Sub
 
Example:           ON KBD.BAS
 
Description:
ON KBD defines an event branch to be taken when a key is pressed. ON KBD ALL traps all alpha-numeric keys and HTBasic function keys except RESET. The following keys are not trapped if ALL is not specified: CLR I/O, MENU, PAUSE, s-MENU, STOP, EXECUTE, USER and any softkeys.
If ON KBD is active, immediate execution of keyboard editing and display control function keys is suspended. All keystrokes go into a special KBD$ buffer. The buffer is cleared when it is read. The event handling routine can selectively execute keys found in KBD$ by including them in an OUTPUT KBD statement:
 
OUTPUT KBD;Buf$;
 
Unless an ON KNOB definition is active, movement of the mouse generates ON KBD interrupts and places UP, DOWN, LEFT or RIGHT keystrokes into the KBD$ buffer. If both ON KBD ALL and ON KEY are active, ON KBD ALL takes precedence over ON KEY.
 
Executing a new ON KBD while another ON KBD is still in effect overrides the previous ON KBD definition. If the ON KBD is executed in a different program context, the original ON KBD definition is restored when control returns to the calling context.
 
ON KBD is canceled by OFF KBD, disabled by DISABLE and temporarily disabled by an LINPUT, INPUT, or ENTER KBD statement. A SUBEXIT, SUBEND, or RETURN from the defining subprogram also cancels it.
 
More information about ON KBD can be found under the "Common Information" heading of the ON CYCLE manual entry.
 
See Also: