diff --git a/sys/apis/input.lua b/sys/apis/input.lua index 75ee1de..a47213a 100644 --- a/sys/apis/input.lua +++ b/sys/apis/input.lua @@ -39,11 +39,11 @@ function input:toCode(ch, code) -- the key-up event for alt keys is not generated if the minecraft -- window loses focus - -- - -- if keyboard.state[keys.leftAlt] or keyboard.state[keys.rightAlt] or - -- code == keys.leftAlt or code == keys.rightAlt then - -- table.insert(result, 'alt') - -- end + + if keyboard.state[keys.leftAlt] or keyboard.state[keys.rightAlt] or + code == keys.leftAlt or code == keys.rightAlt then + table.insert(result, 'alt') + end if keyboard.state[keys.leftShift] or keyboard.state[keys.rightShift] or code == keys.leftShift or code == keys.rightShift then diff --git a/sys/extensions/1.device.lua b/sys/extensions/1.device.lua index 9196c42..2dbdb91 100644 --- a/sys/extensions/1.device.lua +++ b/sys/extensions/1.device.lua @@ -75,21 +75,18 @@ end) local modifiers = Util.transpose { keys.leftCtrl, keys.rightCtrl, keys.leftShift, keys.rightShift, - keys.leftAlt, keys.rightAlt, + --keys.leftAlt, keys.rightAlt, } kernel.hook({ 'key', 'key_up', 'char', 'paste' }, function(event, eventData) local code = eventData[1] - -- maintain global keyboard state + -- maintain global keyboard modifier state if modifiers[code] then if event == 'key' then keyboard.state[code] = true elseif event == 'key_up' then --- if not keyboard.state[code] then --- return true -- ensure key ups are only generated if a key down was sent --- end - keyboard.state[code] = nil + keyboard.state[code] = nil end end @@ -98,6 +95,7 @@ kernel.hook({ 'key', 'key_up', 'char', 'paste' }, function(event, eventData) if hotkey and keyboard.hotkeys[hotkey.code] then keyboard.hotkeys[hotkey.code](event, eventData) + return true end end)