tags:

views:

99

answers:

1

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.

+1  A: 

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.

Anurag