mirror of
https://github.com/kepler155c/opus
synced 2025-01-05 21:30:28 +00:00
keyboard handling
This commit is contained in:
parent
398953af54
commit
3f9c219f6b
@ -39,11 +39,11 @@ function input:toCode(ch, code)
|
|||||||
|
|
||||||
-- the key-up event for alt keys is not generated if the minecraft
|
-- the key-up event for alt keys is not generated if the minecraft
|
||||||
-- window loses focus
|
-- window loses focus
|
||||||
--
|
|
||||||
-- if keyboard.state[keys.leftAlt] or keyboard.state[keys.rightAlt] or
|
if keyboard.state[keys.leftAlt] or keyboard.state[keys.rightAlt] or
|
||||||
-- code == keys.leftAlt or code == keys.rightAlt then
|
code == keys.leftAlt or code == keys.rightAlt then
|
||||||
-- table.insert(result, 'alt')
|
table.insert(result, 'alt')
|
||||||
-- end
|
end
|
||||||
|
|
||||||
if keyboard.state[keys.leftShift] or keyboard.state[keys.rightShift] or
|
if keyboard.state[keys.leftShift] or keyboard.state[keys.rightShift] or
|
||||||
code == keys.leftShift or code == keys.rightShift then
|
code == keys.leftShift or code == keys.rightShift then
|
||||||
|
@ -75,20 +75,17 @@ end)
|
|||||||
local modifiers = Util.transpose {
|
local modifiers = Util.transpose {
|
||||||
keys.leftCtrl, keys.rightCtrl,
|
keys.leftCtrl, keys.rightCtrl,
|
||||||
keys.leftShift, keys.rightShift,
|
keys.leftShift, keys.rightShift,
|
||||||
keys.leftAlt, keys.rightAlt,
|
--keys.leftAlt, keys.rightAlt,
|
||||||
}
|
}
|
||||||
|
|
||||||
kernel.hook({ 'key', 'key_up', 'char', 'paste' }, function(event, eventData)
|
kernel.hook({ 'key', 'key_up', 'char', 'paste' }, function(event, eventData)
|
||||||
local code = eventData[1]
|
local code = eventData[1]
|
||||||
|
|
||||||
-- maintain global keyboard state
|
-- maintain global keyboard modifier state
|
||||||
if modifiers[code] then
|
if modifiers[code] then
|
||||||
if event == 'key' then
|
if event == 'key' then
|
||||||
keyboard.state[code] = true
|
keyboard.state[code] = true
|
||||||
elseif event == 'key_up' then
|
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
|
||||||
end
|
end
|
||||||
@ -98,6 +95,7 @@ kernel.hook({ 'key', 'key_up', 'char', 'paste' }, function(event, eventData)
|
|||||||
|
|
||||||
if hotkey and keyboard.hotkeys[hotkey.code] then
|
if hotkey and keyboard.hotkeys[hotkey.code] then
|
||||||
keyboard.hotkeys[hotkey.code](event, eventData)
|
keyboard.hotkeys[hotkey.code](event, eventData)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user