1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2025-01-11 00:40:03 +01:00
password-manager-mirror/frontend/delta/js/MouseTrap/mousetrap-pause.js

30 lines
678 B
JavaScript
Raw Normal View History

/**
* adds a pause and unpause method to Mousetrap
* this allows you to enable or disable keyboard shortcuts
* without having to reset Mousetrap and rebind everything
*/
/* global Mousetrap:true */
Mousetrap = (function(Mousetrap) {
var self = Mousetrap,
_originalStopCallback = self.stopCallback,
enabled = true;
self.stopCallback = function(e, element, combo) {
if (!enabled) {
return true;
}
return _originalStopCallback(e, element, combo);
};
self.pause = function() {
enabled = false;
};
self.unpause = function() {
enabled = true;
};
return self;
}) (Mousetrap);