Difference between revisions of "ON KEY(n)"

From QB64 Wiki
Jump to navigation Jump to search
Line 40: Line 40:
* [[ON...GOSUB]], [[Scancodes]]
* [[ON...GOSUB]], [[Scancodes]]
* [[_KEYHIT]], [[_KEYDOWN]]

Revision as of 10:52, 11 October 2010

The ON KEY(n) statement defines a line number or label to go to when a specified key is pressed.

Syntax: ON KEY (n) GOSUB {linelabel|linenumber}


1-10 for F1-F10 function keys
11, 12, 13 and 14 for UP, LEFT, RIGHT and DOWN numberpad arrows respectively.
15-25 for user-defined keys. See: Keyboard scancodes
30 and 31 for F11 and F12 function keys


KEY(1) ON ON KEY (1) GOSUB trap PRINT "Press F1 to quit!" DO:LOOP 'never ending loop trap: PRINT "You pressed F1 like I told you to :)" END RETURN

See also:

Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page