From 2c3e393a6fa85b98e1ebbf23d85341868f42f599 Mon Sep 17 00:00:00 2001 From: rxi Date: Sun, 29 Dec 2019 16:09:56 +0000 Subject: [PATCH] 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 --- data/core/keymap.lua | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/data/core/keymap.lua b/data/core/keymap.lua index 0493b7a..64c5757 100644 --- a/data/core/keymap.lua +++ b/data/core/keymap.lua @@ -5,19 +5,16 @@ keymap.modkeys = {} keymap.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 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 stroke = "" for _, mk in ipairs(modkeys) do @@ -55,7 +52,7 @@ end function keymap.on_key_pressed(k) - local mk = modkey(k) + local mk = modkey_map[k] if mk then keymap.modkeys[mk] = true else @@ -74,7 +71,7 @@ end function keymap.on_key_released(k) - local mk = modkey(k) + local mk = modkey_map[k] if mk then keymap.modkeys[mk] = false end