Skip to content

Key events not captured when page content loses focus then regains it #16

Open
jshou opened this Issue Sep 3, 2011 · 14 comments

7 participants

@jshou
jshou commented Sep 3, 2011

If I click the location bar, then the webpage again, key events seem to not be captured. The same goes for if I use a keyboard shortcut to launch Developer Tools and turn it off again. The key events get captured again if I switch to a different tab and back, or if I reload the page. Can anyone reproduce this?

I'm on a Mac, using Chrome 13.0.782.218

@micsco
micsco commented Sep 3, 2011

I can reproduce launching Developer tools, though do not have location bar issue. I have also notice the issue after a certain amount of time having a tab open in background. I'd say these a chrome bugs, not sure what a fix would be though.

Using Chrome 14.0.835.126 beta on OSX v10.7.1

@jshou
jshou commented Sep 3, 2011

It's kind of hard to debug this given that it has to do with opening and closing the debugger. I can deal with having the debugger problem there, but the location bar bug is a little irksome.

@jshou
jshou commented Sep 3, 2011

I tried again with 14.0.835.126 beta, same problem with both the location bar and Developer tools. OSX 10.6.8.

@livibetter

Chromium 13.0.782.215 on Linux

I think I identify the cause of Developer Tools. If you press Ctrl+Shift+I/J to bring up developer tools.

The states of Shift and Control keys in _mod will be stuck as true because keymaster does not receive a keyup event.

If you press Shift and Control after you make page regain focus, the states will be corrected. And it will work again.

I try to "switch tab" but it doesn't work also location bar does not affect. I wonder if that's result of mixed testing.

Reload does work since the code restart.

@livibetter livibetter added a commit to fkeymaster/fkeymaster that referenced this issue Sep 4, 2011
@livibetter livibetter Fix modifier key states can not be set correctly when bring up Develo…
…per Tool using keyboard shortcut. Fixes madrobby/keymaster#16.

It also affects shortcuts which will pop up new window, such as Save As (Ctrl+S),
but not New Tab (Ctrl+T).

The keyup event has never been sent to clearModifier(), therefore the
state is still true, it won't get cleared.

This is an ugly fix.
cfd0737
@livibetter

@jshou this has just come to me, about the location bar, by any chance you were actually pressing Alt+D (not click on it), then click back on the page? It would cause the same issue.

@jshou
jshou commented Sep 4, 2011

@livibetter, you are exactly right, I hadn't made that connection. I tried hitting Command again and it cleared the state. I'll try the fix, thanks!

@jshou
jshou commented Sep 4, 2011

@livibetter, I tried pulling the tree from that commit and using keymaster.js, but then none of my ctrl+shift shortcuts worked, I haven't tested this further to see what's causing it though.

@livibetter

I just tried to add ctrl+shift+z and it still works.

were you trying to use keymaster.js from my fork in the page you are currently working on? My fork has become quite a different fork from original code. I don't think you can simply apply.

(PS. you can message me if you need more help with my fork, but I think fix might come up soon)

@harryhorn

I am seeing similar issues simply by switching to a different application and then switching back using command+tab on a mac. This happens even on Firefox. Seems like the issue is that the Command modifier remains set when you switch back ... pushing it down once brings back everything to normal ... I will see if I can use the above fix

@kulesa
kulesa commented Oct 20, 2011

I am also having this issue on a mac, in Chrome / Safari / FF. Sometimes after switching with ⌘+Tab to other application and back, the ⌘ modifier remains set.

@itay
itay commented Nov 3, 2011

Same issue here on Chrome with OS+X and pressing Cmd+L to go to the location bar.

@lowe
lowe commented Nov 6, 2011

Hey all, i tried a few scenarios already, but lemme know if this fix doesn't solve your problem.

@harryhorn

Hey Lowe, tried your fix, seems to work OK. Thanks!

@kulesa
kulesa commented Nov 8, 2011

@lowe, it didn't help in my case. When I switch to other window and back by QUICKLY hitting ⌘+tab, the command modifier being reset as expected. But if I hold down Command key before switching to the other window for a little longer (for about a second), then after I switch back Command modifier remains set.

I checked that resetModifiers() being called in both cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.