Skip to content

Commit

Permalink
Guard against use of "document" madrobby#183 #1
Browse files Browse the repository at this point in the history
Guard against use of "document" madrobby#183
  • Loading branch information
wtachau authored Sep 6, 2021
2 parents f8f43dd + 8af9aa7 commit 523ffd0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions keymaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,13 @@
};

// 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 window !== 'undefined' && window.document) {
addEvent(window.document, 'keydown', function(event) { dispatch(event) }); // Passing _scope to a callback to ensure it remains the same by execution. Fixes #48
addEvent(window.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

0 comments on commit 523ffd0

Please sign in to comment.