Permalink
Browse files

reset modifiers to false on window focus. fixes issues with alt+tab, …

…switching browser tabs with the keyboard, etc
  • Loading branch information...
1 parent 0a96e36 commit b8e03be67ee209fbf63a4c43e4601f491f76c417 @lowe lowe committed Nov 6, 2011
Showing with 11 additions and 0 deletions.
  1. +11 −0 keymaster.js
View
@@ -94,6 +94,14 @@
}
};
+ function resetModifiers() {
+ for (k in _mods) {
+ if (_mods.hasOwnProperty(k)) {
+ _mods[k] = false;
+ }
+ }
+ }
+
// parse and assign shortcut
function assignKey(key, scope, method){
var keys, mods, i, mi;
@@ -144,6 +152,9 @@
addEvent(document, 'keydown', dispatch);
addEvent(document, 'keyup', clearModifier);
+ // reset modifiers to false whenever the window is (re)focused.
+ addEvent(window, 'focus', resetModifiers);
+
// set window.key and window.key.setScope
global.key = assignKey;
global.key.setScope = setScope;

0 comments on commit b8e03be

Please sign in to comment.