1
0
mirror of https://github.com/20kdc/OC-KittenOS.git synced 2024-09-28 14:41:06 +10:00
OC-KittenOS/apps/keycodes.lua

30 lines
579 B
Lua
Raw Normal View History

local math, table = A.request("math", "table")
local app = {}
local strs = {"", "Shift-C to quit."}
local keys = {}
local function rebuildKeys()
local keylist = {}
for k, v in pairs(keys) do
if v then
table.insert(keylist, k)
end
end
table.sort(keylist)
strs[1] = ""
for _, v in ipairs(keylist) do
strs[1] = strs[1] .. v .. " "
end
end
app.key = function(ka, kc, down)
if ka == ("C"):byte() and down then
A.die()
return false
end
keys[kc] = down
rebuildKeys()
return true
end
app.get_ch = function (x, y)
return (strs[y]):sub(x, x)
end
return app, 20, 2