Advertisement
funnybunnyofdoom

Keyreader.lua

Nov 2nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. --This program reads and displays each key press visually.
  2. --It displays all events in a visually pleasing manner
  3. --There is a section for "other" that can be expanded in the future
  4.  
  5. while true do
  6.    
  7.     local event, param1, param2, param3 = os.pullEvent()
  8.     if event == "key" then
  9.     term.setCursorPos(1,1)
  10.     print(event)
  11.     term.setCursorPos(1,2)
  12.     print(param1..' ')
  13.     term.setCursorPos(1,3)
  14.     print(tostring(param2)..' ')
  15.    
  16.     elseif event == "char" then
  17.     term.setCursorPos(8,1)
  18.     print(event)
  19.     term.setCursorPos(8,2)
  20.     print(param1)
  21.      
  22.     elseif event == "key_up" then
  23.     term.setCursorPos(16,1)
  24.     print(event)
  25.     term.setCursorPos(16,2)
  26.     print(param1..' ')
  27.    
  28.     elseif event == "mouse_click" then
  29.     term.setCursorPos(1,5)
  30.     print(event)
  31.     term.setCursorPos(1,6)
  32.     print(tostring(param1)..'  ')
  33.     term.setCursorPos(1,7)
  34.     print(tostring(param2)..'  ')
  35.     term.setCursorPos(1,8)
  36.     print(tostring(param3)..'  ')
  37.    
  38.     elseif event == "mouse_up" then
  39.     term.setCursorPos(13,5)
  40.     print(event)
  41.     term.setCursorPos(13,6)
  42.     print(tostring(param1)..'  ')
  43.     term.setCursorPos(13,7)
  44.     print(tostring(param2)..'  ')
  45.     term.setCursorPos(13,8)
  46.     print(tostring(param3)..'  ')
  47.    
  48.     elseif event == "mouse_scroll" then
  49.     term.setCursorPos(23,5)
  50.     print(event)
  51.     term.setCursorPos(23,6)
  52.     print(tostring(param1)..'  ')
  53.     term.setCursorPos(23,7)
  54.     print(tostring(param2)..'  ')
  55.     term.setCursorPos(23,8)
  56.     print(tostring(param3)..'  ')
  57.    
  58.     elseif event == "mouse_drag" then
  59.     term.setCursorPos(1,10)
  60.     print(event)
  61.     term.setCursorPos(1,11)
  62.     print(tostring(param1)..'  ')
  63.     term.setCursorPos(1,12)
  64.     print(tostring(param2)..'  ')
  65.     term.setCursorPos(1,13)
  66.     print(tostring(param3)..'  ')
  67.    
  68.     elseif event == "monitor_touch" then
  69.     term.setCursorPos(12,10)
  70.     print(event)
  71.     term.setCursorPos(12,11)
  72.     print(tostring(param1)..'  ')
  73.     term.setCursorPos(12,12)
  74.     print(tostring(param2)..'  ')
  75.     term.setCursorPos(12,13)
  76.     print(tostring(param3)..'  ')
  77.    
  78.     else
  79.     term.setCursorPos(27,10)
  80.     print(event..'      ')
  81.     term.setCursorPos(27,11)
  82.     print(tostring(param1)..'      ')
  83.     term.setCursorPos(27,12)
  84.     print(tostring(param2)..'      ')
  85.     term.setCursorPos(27,13)
  86.     print(tostring(param3)..'      ')
  87.     end
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement