diff --git a/src/lua/core/computer.lua b/src/lua/core/computer.lua index a6f8e73..4e32102 100644 --- a/src/lua/core/computer.lua +++ b/src/lua/core/computer.lua @@ -110,15 +110,17 @@ function computer.signalTransformers.key_down(s, a, ascii, key, user) return s, a, ascii, key, user end if ascii == 27 then - inesc_down = true + inesc_down = native.uptime() / 1000 return nil elseif inesc_down then if (ascii < 48 or ascii > 57) and ascii ~= 59 and ascii ~= 91 then inesc_down = false key = escmap[ascii] or 0 ascii = 0 - else + elseif native.uptime() - inesc_down > 100 then -- 100ms timeout after {ESC} return nil + else + inesc_down = false end end return s, a, math.floor(asciitr[ascii] or ascii), keymap[ascii] or key, user @@ -130,15 +132,17 @@ function computer.signalTransformers.key_up(s, a, ascii, key, user) return s, a, ascii, key, user end if ascii == 27 then - inesc_up = true + inesc_up = native.uptime() / 1000 return nil elseif inesc_up then if (ascii < 48 or ascii > 57) and ascii ~= 59 and ascii ~= 91 then inesc_up = false key = escmap[ascii] or 0 ascii = 0 - else + elseif native.uptime() - inesc_up > 100 then -- 100ms timeout after {ESC} return nil + else + inesc_up = false end end return s, a, math.floor(asciitr[ascii] or ascii), keymap[ascii] or key, user