Advertisement
guitarplayer616

Untitled

May 28th, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.43 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. local pressedKey = nil
  4. local pressedChar = nil
  5.  
  6. function key()
  7.   pressedKey = {os.pullEvent("key")}
  8. end
  9.  
  10. function char()
  11.   pressedChar = {os.pullEvent("char")}
  12. end
  13.  
  14. while true do
  15.   pressedKey = {}
  16.   pressedChar = {}
  17.   parallel.waitForAny(key, char)
  18.   if pressedChar[1] then
  19.     print("char: "..pressedChar[2])
  20.   elseif pressedKey[1] then
  21.     print("key: "..pressedKey[2])
  22.   end
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement