Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset modifiers to false on window focus. fixes alt+tab, tab switching, and related issues #32

Merged
merged 1 commit into from
Nov 11, 2011

Conversation

lowe
Copy link
Contributor

@lowe lowe commented Nov 6, 2011

proposed fix for issue #16, including these example problems:

  • when I alt+tab away from the browser to another application, the window doesn't get the keyup events, so _mods[alt] stays true after I navigate back. to reproduce:

key('d', function () {
console.log('pressed d!');
});

alt+tab to another program.
navigate back to the browser.
press 'd', nothing happens.

  • same issue when I use shift+command+] to switch browser tabs on mac (or any other tab-switching shortcut that involves modifiers).
  • here's a sweet one :) same issue when i do:

key('ctrl+c', function () {
alert('pressed ctrl+c!');
}) ;

alert() takes focus away from the window, so after i click 'ok', alert() will keep getting called every time I press 'c' without the modifier.

fix:

reset _mod values to false every time the window is focused. i experimented with document vs window, and focus vs blur, and window focus is the only event that works for every scenario. tested on Chrome/FF/Safari.

…switching browser tabs with the keyboard, etc
madrobby added a commit that referenced this pull request Nov 11, 2011
reset modifiers to false on window focus. fixes alt+tab, tab switching, and related issues
@madrobby madrobby merged commit e9c78d3 into madrobby:master Nov 11, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants