This shows you the differences between two versions of the page.
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] 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. | + | 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/ | ||
==== Note ==== | ==== Note ==== | ||
Line 39: | Line 42: | ||
print a+" | print a+" | ||
goto loop | goto loop | ||
+ | </ | ||
+ | |||
+ | ====Example==== | ||
+ | < | ||
+ | # 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 | ||
</ | </ | ||
==== See Also ==== | ==== See Also ==== | ||
{{page> | {{page> | ||
+ | |||
+ | ==== History ==== | ||
+ | |2.0.0.11|added optional Unicode character argument| | ||
+ |