Skip to content

Commit

Permalink
Merge pull request #32 from lowe/alttab
Browse files Browse the repository at this point in the history
reset modifiers to false on window focus. fixes alt+tab, tab switching, and related issues
  • Loading branch information
madrobby committed Nov 11, 2011
2 parents 0a96e36 + b8e03be commit e9c78d3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions keymaster.js
Expand Up @@ -94,6 +94,14 @@
} }
}; };


function resetModifiers() {
for (k in _mods) {
if (_mods.hasOwnProperty(k)) {
_mods[k] = false;
}
}
}

// parse and assign shortcut // parse and assign shortcut
function assignKey(key, scope, method){ function assignKey(key, scope, method){
var keys, mods, i, mi; var keys, mods, i, mi;
Expand Down Expand Up @@ -144,6 +152,9 @@
addEvent(document, 'keydown', dispatch); addEvent(document, 'keydown', dispatch);
addEvent(document, 'keyup', clearModifier); 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 // set window.key and window.key.setScope
global.key = assignKey; global.key = assignKey;
global.key.setScope = setScope; global.key.setScope = setScope;
Expand Down

0 comments on commit e9c78d3

Please sign in to comment.