Difference between revisions of "ON KEY(n)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 2: Line 2:
  
  
:::''Syntax:'' ON KEY (n) [[GOSUB]] {linelabel|linenumber}
+
{{PageSyntax}}
 
+
:: ON KEY (n) [[GOSUB]] {linelabel|linenumber}
  
  
Line 19: Line 19:
  
 
''Example:''
 
''Example:''
{{CodeStart}}
+
{{CodeStart}} '' ''
'' ''
 
 
{{Cl|KEY(n)|KEY(1) ON}}
 
{{Cl|KEY(n)|KEY(1) ON}}
 
{{Cl|ON KEY(n)|ON KEY}}(1) {{Cl|GOSUB}} trap
 
{{Cl|ON KEY(n)|ON KEY}}(1) {{Cl|GOSUB}} trap
Line 31: Line 30:
 
{{Cl|RETURN}} '' ''
 
{{Cl|RETURN}} '' ''
 
{{CodeEnd}}
 
{{CodeEnd}}
 
  
  
 
''See also:''  
 
''See also:''  
 
 
* [[KEY(n)]], [[KEY n]] (soft key)
 
* [[KEY(n)]], [[KEY n]] (soft key)
 
 
* [[ON...GOSUB]], [[Scancodes]]
 
* [[ON...GOSUB]], [[Scancodes]]
 
 
* [[_KEYHIT]], [[_KEYDOWN]]
 
* [[_KEYHIT]], [[_KEYDOWN]]
 
  
  
 
{{PageNavigation}}
 
{{PageNavigation}}

Revision as of 23:29, 9 May 2011

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}


Description:

  • The keys apply to the list of keys shown below, where n is the number that represents that key.
1-10 for F1-F10 function keys respectively
11, 12, 13 and 14 for UP, LEFT, RIGHT and DOWN numberpad arrows respectively.
15-25 for user-defined keys. See: KEY n, Keyboard scancodes
30 and 31 for F11 and F12 function keys


Example:

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:



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