-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathdual-key-remap.lua
More file actions
50 lines (43 loc) · 1.11 KB
/
dual-key-remap.lua
File metadata and controls
50 lines (43 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function Key(name, opts)
local key = {}
key.name = name
key.dir = opts and opts.dir or 0
key.full_name = name
if key.dir > 0 then
key.full_name = key.full_name .. (key.dir == 1 and " (left)" or " (right)")
end
return key
end
local function autotable()
return setmetatable({}, {
__index = function(t, k)
t[k] = autotable()
return t[k]
end
})
end
function dump(t, indent)
indent = indent or 0
local spaces = string.rep(" ", indent)
if type(t) ~= "table" then
print(spaces .. tostring(t))
return
end
print(spaces .. "{")
for k, v in pairs(t) do
local key = type(k) == "string" and k or "[" .. tostring(k) .. "]"
if type(v) == "table" then
print(spaces .. " " .. key .. " = ")
dump(v, indent + 1)
else
print(spaces .. " " .. key .. " = " .. tostring(v))
end
end
print(spaces .. "}")
end
escape = Key("escape")
ctrl = Key("ctrl")
enter = Key("enter")
rshift = Key("shift", { dir = 2 })
capslock = Key("capslock")
remap = autotable()