Difference between revisions of "Key (event)"
From ComputerCraft Wiki
MKlegoman357 (Talk | contribs) (Updated to ComputerCraft 1.74) |
MKlegoman357 (Talk | contribs) m |
||
Line 1: | Line 1: | ||
+ | {{Lowercase}} | ||
{{Event | {{Event | ||
|name=key | |name=key |
Revision as of 11:32, 28 June 2015
Example | |
Print each key pressed on the keyboard whenever a "key" event is fired. Use Ctrl+T (Windows) to terminate the loop. | |
Code |
while true do local event, key, isHeld = os.pullEvent("key") write( keys.getName( key ) ) print( isHeld and " is being held." or " was pressed." ) end |
Output | Any key that is pressed. |
Key scan codes
These scan codes are also available as constants in the keys API, and can be translated from numerical codes to strings using keys.getName.