Reputation: 19003
I have 2 keydown handlers:
$(document).bind('keydown', function(e) {
if (e.keyCode == 75) {
// handler1 strategy
} else if (e.keyCode == 78) {
// handler2 strategy
}
});
How can I unbind one handler without affecting all the other keydown handlers?
updated.
Upvotes: 1
Views: 727
Reputation: 141879
You could create a plugin that maintains a map of key combinations, and associated functions. Whenever it sees a keydown event, it calls each matching function. Removal of an existing handler will be easy too.
Upvotes: 1