mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-04-03 22:52:48 +02:00
Переходим на MineOS Standalone #1
This commit is contained in:
41
Libraries/Keyboard.lua
Executable file
41
Libraries/Keyboard.lua
Executable file
@@ -0,0 +1,41 @@
|
||||
|
||||
local keyboard = {}
|
||||
local pressedCodes = {}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
function keyboard.isKeyDown(code)
|
||||
checkArg(1, code, "number")
|
||||
|
||||
return pressedCodes[code]
|
||||
end
|
||||
|
||||
function keyboard.isControl(code)
|
||||
return type(code) == "number" and (code < 32 or (code >= 127 and code <= 159))
|
||||
end
|
||||
|
||||
function keyboard.isAltDown(address)
|
||||
return pressedCodes[56] or pressedCodes[184]
|
||||
end
|
||||
|
||||
function keyboard.isControlDown(address)
|
||||
return pressedCodes[29] or pressedCodes[157]
|
||||
end
|
||||
|
||||
function keyboard.isShiftDown(address)
|
||||
return pressedCodes[42] or pressedCodes[54]
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
require("Event").addHandler(function(e1, _, _, e4)
|
||||
if e1 == "key_down" then
|
||||
pressedCodes[e4] = true
|
||||
elseif e1 == "key_up" then
|
||||
pressedCodes[e4] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
return keyboard
|
||||
Reference in New Issue
Block a user