Difference between revisions of "ON KEY (n)"

From QB64 Wiki
Jump to navigation Jump to search
Line 29: Line 29:
  
  
''See also:'' [[KEY(n)]]
+
''See also:'' [[KEY(n)]], [[ON...GOSUB]]
  
  

Revision as of 03:26, 7 October 2009

ON KEY (n) defines a line number or label to go to when that key is struck, the keys apply to the list of keys shown below, where n is the number that represents that key.


Syntax: ON KEY (n) GOSUB linelabel/number


  • n can be any of the following:
1-10 for F1-F10.
11, 12, 13 and 14 for UP, LEFT, RIGHT and DOWN arrows respectively.
15-25 for user-defined keys.
30 and 31 for F11 and F12.


Example:

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


See also: KEY(n), ON...GOSUB


Navigation:

Go to Keyword Reference - Alphabetical

Go to Keyword Reference - By usage