Debian Codegraph @

plugins/pause/mousetrap-pause.js

raw symbols SCIP
1 /**
2 * adds a pause and unpause method to Mousetrap
3 * this allows you to enable or disable keyboard shortcuts
4 * without having to reset Mousetrap and rebind everything
5 */
6 /* global Mousetrap:true */
7 (function(Mousetrap) {
8 var _originalStopCallback = Mousetrap.prototype.stopCallback;
9
10 Mousetrap.prototype.stopCallback = function(e, element, combo) {
11 var self = this;
12
13 if (self.paused) {
14 return true;
15 }
16
17 return _originalStopCallback.call(self, e, element, combo);
18 };
19
20 Mousetrap.prototype.pause = function() {
21 var self = this;
22 self.paused = true;
23 };
24
25 Mousetrap.prototype.unpause = function() {
26 var self = this;
27 self.paused = false;
28 };
29
30 Mousetrap.init();
31 }) (Mousetrap);