Open lidortal opened 8 years ago
Indeed, I tried it too in jsfiddle and I wasn't able to unbind it.
What I could do to temporary solve is to bind it again with empty function callback.
Mousetrap.bindGlobal('ctrl+s', function() { alert("Hi!"); }); Mousetrap.bindGlobal('ctrl+s', function() { /* do nothing */ });
I have run into the same issue when using bindGlobal and then later needing to clear everything with Mousetrap.reset().
My keyboard shortcuts are built dynamically based on server response, is there a way to get all the current Mousetrap bindings programmatically in order to assign them empty functions?
+1 for this. I want esc
to close the sidebar when it's open but I also need esc
to do other things throughout the application. I'm using Ember so the keypress bind/unbinds are dynamic as components are rendered. unbinding one component that listens to esc
unbinds them all.
+1. A use case for this is to have global shortcuts for different pages in an app. It must be possible to unbind them. Also I think It is programmer friendlier to have the methods in pairs bind/unbind bindGlobal/unbindGlobal (I expected this behaviour and it didn't work 😅). We are currently using #353 in some apps. Seems to be working as expected.
Hi, how do I unbind global shortcut? I did the following: Mousetrap.bindGlobal('ctrl+s', function() { alert("Hi!"); }); .... Mousetrap.unbind('ctrl+s');
However when pressing ctrl+s I still get the Hi! message. Thanks!