Permalink
Browse files

Merge pull request #1 from devongovett/master

Got it working in Firefox
  • Loading branch information...
2 parents 48653f3 + e27b1e4 commit 6cbedd406fd619c6331d752a7dfcef0d2bdf10e1 @madrobby madrobby committed Aug 27, 2011
Showing with 6 additions and 6 deletions.
  1. +6 −6 keymaster.js
View
@@ -17,8 +17,8 @@
function dispatch(event){
var key, tagName;
- tagName = event.srcElement.tagName;
- key = event.keyCode.toString();
+ tagName = event.target.tagName;
+ key = '' + event.keyCode;
if(key in _mods) return _mods[key] = true;
if (tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA') return;
if (!(key in _handlers)) return;
@@ -31,8 +31,8 @@
}
function clearModifier(event){
- var key = event.keyCode.toString();
- if(key in _mods) _mods[key] = false;
+ var key = '' + event.keyCode;
+ if(key in _mods) _mods[key] = false;
}
function assignKey(key, scope, method){
@@ -59,8 +59,8 @@
function setScope(scope){ _scope = scope || 'all' }
- document.body.addEventListener('keydown', dispatch);
- document.body.addEventListener('keyup', clearModifier);
+ document.addEventListener('keydown', dispatch, false);
+ document.addEventListener('keyup', clearModifier, false);
global.key = assignKey;
global.keyScope = setScope;
})(this);

0 comments on commit 6cbedd4

Please sign in to comment.