Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions keymaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@

if (keys.length > 1) {
mods = getMods(keys);
key = keys[keys.length - 1];
}

key = keys[keys.length - 1];
key = code(key);

if (scope === undefined) {
Expand Down Expand Up @@ -263,12 +263,15 @@
object.attachEvent('on'+event, function(){ method(window.event) });
};

// set the handlers globally on document
addEvent(document, 'keydown', function(event) { dispatch(event) }); // Passing _scope to a callback to ensure it remains the same by execution. Fixes #48
addEvent(document, 'keyup', clearModifier);

// reset modifiers to false whenever the window is (re)focused.
addEvent(window, 'focus', resetModifiers);
if(typeof document !== 'undefined'){
// set the handlers globally on document
addEvent(document, 'keydown', function(event) { dispatch(event) }); // Passing _scope to a callback to ensure it remains the same by execution. Fixes #48
addEvent(document, 'keyup', clearModifier);

// reset modifiers to false whenever the window is (re)focused.
addEvent(window, 'focus', resetModifiers);
}

// store previously defined key
var previousKey = global.key;
Expand Down