keymaster icon indicating copy to clipboard operation
keymaster copied to clipboard

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

Open jshou opened this issue 13 years ago • 14 comments

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

jshou avatar Sep 03 '11 19:09 jshou

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

micsco avatar Sep 03 '11 22:09 micsco

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 avatar Sep 03 '11 23:09 jshou

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

jshou avatar Sep 03 '11 23:09 jshou

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 avatar Sep 04 '11 11:09 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.

livibetter avatar Sep 04 '11 12:09 livibetter

@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 avatar Sep 04 '11 15:09 jshou

@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.

jshou avatar Sep 04 '11 16:09 jshou

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)

livibetter avatar Sep 04 '11 17:09 livibetter

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

harryhorn avatar Oct 07 '11 16:10 harryhorn

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.

kulesa avatar Oct 20 '11 07:10 kulesa

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

itay avatar Nov 03 '11 07:11 itay

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

lowe avatar Nov 06 '11 05:11 lowe

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

harryhorn avatar Nov 08 '11 06:11 harryhorn

@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.

kulesa avatar Nov 08 '11 07:11 kulesa