Difference between revisions of "Char (event)"
From ComputerCraft Wiki
(Created event page.) |
m (better coding habits) |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | |||
| − | |||
{{Event | {{Event | ||
|name=char | |name=char | ||
|desc=Fired when a alphanumeric key is pressed on the keyboard. | |desc=Fired when a alphanumeric key is pressed on the keyboard. | ||
|return1=The [[String_(type)|String]] representing the character that was pressed. | |return1=The [[String_(type)|String]] representing the character that was pressed. | ||
| + | }} | ||
| + | {{Example | ||
| + | |desc=Prints out the character that was pressed. | ||
| + | |code= | ||
| + | while true do | ||
| + | local event, character = os.pullEvent("char") | ||
| + | print(character.." was pressed.") | ||
| + | end | ||
| + | |output=The key that was pressed. Note this doesn't trigger for Tab, Shift, the up arrow, etc. Use the [[key_(event)|key]] event if you wish to trap those keys. | ||
}} | }} | ||
Latest revision as of 09:30, 28 October 2013
| Fired when a alphanumeric key is pressed on the keyboard. | |
| Returned Object 1 | The String representing the character that was pressed. |
| Prints out the character that was pressed. | |
| Code |
while true do
local event, character = os.pullEvent("char")
print(character.." was pressed.")
end
|
| Output | The key that was pressed. Note this doesn't trigger for Tab, Shift, the up arrow, etc. Use the key event if you wish to trap those keys. |