Code: Select all
Text = ''
function love.draw()
love.graphics.setColor(1,1,1)
love.graphics.print(Text)
end
function love.keypressed(key, scancode, isrepeat)
if key == 'tab' then
Text = Text..key
elseif key == 'escape' then
Text = ''
end
end
Open it up, hit tab a few times. See that it works as expected.
Switch back and forth between this window and one other one using alt-tab.
Expected result: nothing is printed as you alt-tab back and forth.
Observed result: on Linux I see 'tab' print some of the time when I alt-tab quickly. If I alt-tab slowly (i.e. press alt and hold, press tab and release, see the LÖVE thumbnail focused in the switcher, release alt to switch to the window) everything works as expected. However if I switch so quickly that the switcher doesn't have time to show up, I see 'tab' printed some of the time.
I'm curious if others are able to reproduce this behavior, and on other platforms besides Linux.
I suspect (based on printing out keypressed and keyreleased events) that this is happening because when I switch windows I'm sometimes letting go of the 'alt' before the 'tab'. If that's true it seems a bit surprising since releasing one key ('alt') is creating a keypress event for a different one ('tab').
Any thoughts or workarounds most appreciated.