key (event)
From ComputerCraft Wiki
Revision as of 11:32, 28 June 2015 by MKlegoman357 (Talk | contribs)
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.