Advertisement
1lann

keyboard-shortcut

Feb 25th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. function keyCheck()
  2.     local sTimer = "placeholder"
  3.     local seTimer = "placeholder"
  4.     local allowChar = false
  5.     local shiftPressed = false
  6.     while true do
  7.         local event, char = os.pullEvent()
  8.         if event == "key" and char == 42 then
  9.             shiftPressed = true
  10.             seTimer = os.startTimer(0.7)
  11.         elseif event == "key" and char == 29 then
  12.             allowChar = true
  13.             sTimer = os.startTimer(0.7)
  14.         elseif event == "key" and allowChar then
  15.             local name = nil
  16.             for k,v in pairs(keys) do
  17.                 if v == char then
  18.                     if shiftPressed then
  19.                     print("Ctrl+" .. "Shift+" .. k:upper())
  20.                     else
  21.                     print("Ctrl+" .. k:upper())
  22.                     end
  23.                 end
  24.             end
  25.         elseif event == "timer" and char == sTimer then
  26.             allowChar = false
  27.         elseif event == "timer" and char == seTimer then
  28.             shiftPressed = false
  29.         end
  30.     end
  31. end
  32. keyCheck()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement