User Tools

Site Tools


en:key

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:key [2016/08/12 12:51]
admin
en:key [2020/06/29 17:41] (current)
admin
Line 2: Line 2:
 ==== Format ==== ==== Format ====
 key\\ key\\
-key()+key()\\ 
 +key([[booleanexpressions|getUnicode]])
  
 returns [[integerexpressions|integer_expression]] returns [[integerexpressions|integer_expression]]
  
 ==== Description ==== ==== Description ====
-Immediately returns an integer value corresponding to the currently pressed keyboard key.  If no key has been pressed since the last call to the **key** function then the number zero (0) will be returned.  This function returns the code for the key pressed not always the ASCII value of the character.+Immediately returns an integer value corresponding to the currently pressed keyboard key (if the argument is omitted or false), returns the Unicode character number if the argument is true.  If no key has been pressed since the last call to the **key** function then the number zero (0) will be returned. 
 + 
 +In Unicoide mode the key function will not return keypresses like backspace, escape, arrows, shift, alt, or the control keys.  It will return upper/lowercase letters.
  
 ==== Note ==== ==== Note ====
Line 39: Line 42:
 print a+"  "+chr(a) print a+"  "+chr(a)
 goto loop goto loop
 +</code>
 +
 +====Example====
 +<code>
 +# get unicode letters until you press a control x
 +while true
 + k = key(true)
 + if k <> 0 then
 + print k, chr(k)
 + if k = 24 then exit while
 + endif
 + pause .1
 +end while
 </code> </code>
  
 ==== See Also ==== ==== See Also ====
 {{page>en:start#Keyboard and User Input&noheader}} {{page>en:start#Keyboard and User Input&noheader}}
 +
 +==== History ==== 
 +|2.0.0.11|added optional Unicode character argument|
 +
en/key.1471027899.txt.gz · Last modified: 2020/02/28 10:46 (external edit)