Skip to content
Open
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions keymaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,24 @@
function setScope(scope){ _scope = scope || 'all' };
function getScope(){ return _scope || 'all' };

// unbind all handlers for given key in current scope
function unbindKey(key, scope) {
key = _MAP[key] || key.toUpperCase().charCodeAt(0);
if (scope === undefined) {
scope = getScope();
}
if (!_handlers[key]) {
return;
}
var i;
for (i in _handlers[key]) {
obj = _handlers[key][i];
if (obj.scope === scope) {
_handlers[key][i] = {};
}
}
}

// delete all handlers for a given scope
function deleteScope(scope){
var key, handlers, i;
Expand Down Expand Up @@ -178,6 +196,7 @@
global.key.getScope = getScope;
global.key.deleteScope = deleteScope;
global.key.filter = filter;
global.key.unbind = unbindKey;

if(typeof module !== 'undefined') module.exports = key;

Expand Down
17 changes: 16 additions & 1 deletion keymaster.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.