Changed keymap to only treat left alt as alt modkey

This prevents AltGr from being treated as the `alt` modkey. Previously
its default behaviour would have been overridden if the keymap had an
`alt+...` stroke bound
This commit is contained in:
rxi 2019-12-29 16:09:56 +00:00
parent b798825e7c
commit 2c3e393a6f

View file

@ -5,19 +5,16 @@ keymap.modkeys = {}
keymap.map = {} keymap.map = {}
keymap.reverse_map = {} keymap.reverse_map = {}
local modkey_map = {
["left ctrl"] = "ctrl",
["right ctrl"] = "ctrl",
["left shift"] = "shift",
["right shift"] = "shift",
["left alt"] = "alt",
}
local modkeys = { "ctrl", "alt", "shift" } local modkeys = { "ctrl", "alt", "shift" }
local function modkey(key)
for _, k in ipairs(modkeys) do
if key:find(k) then
return k
end
end
return false
end
local function key_to_stroke(k) local function key_to_stroke(k)
local stroke = "" local stroke = ""
for _, mk in ipairs(modkeys) do for _, mk in ipairs(modkeys) do
@ -55,7 +52,7 @@ end
function keymap.on_key_pressed(k) function keymap.on_key_pressed(k)
local mk = modkey(k) local mk = modkey_map[k]
if mk then if mk then
keymap.modkeys[mk] = true keymap.modkeys[mk] = true
else else
@ -74,7 +71,7 @@ end
function keymap.on_key_released(k) function keymap.on_key_released(k)
local mk = modkey(k) local mk = modkey_map[k]
if mk then if mk then
keymap.modkeys[mk] = false keymap.modkeys[mk] = false
end end