2020-06-06 00:03:37 +02:00
|
|
|
"use strict";
|
2016-04-14 21:01:33 +02:00
|
|
|
|
2020-06-06 00:03:37 +02:00
|
|
|
const mousetrap = require("mousetrap");
|
|
|
|
const settings = require("../models/settings.js");
|
2016-04-14 21:01:33 +02:00
|
|
|
|
2016-07-22 13:27:52 +02:00
|
|
|
let paused = false;
|
|
|
|
const _originalStopCallback = mousetrap.prototype.stopCallback;
|
2020-06-04 20:09:35 +02:00
|
|
|
// eslint-disable-next-line func-names
|
2020-06-06 00:03:37 +02:00
|
|
|
mousetrap.prototype.stopCallback = function (...args) {
|
2016-07-22 13:27:52 +02:00
|
|
|
var self = this;
|
|
|
|
if (paused) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return _originalStopCallback.call(self, ...args);
|
|
|
|
};
|
|
|
|
|
2016-04-14 21:01:33 +02:00
|
|
|
function bind(hotkey, func) {
|
2016-06-14 10:31:48 +02:00
|
|
|
if (settings.get().keyboardShortcuts) {
|
2016-04-14 21:01:33 +02:00
|
|
|
mousetrap.bind(hotkey, func);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function unbind(hotkey) {
|
|
|
|
mousetrap.unbind(hotkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
bind: bind,
|
|
|
|
unbind: unbind,
|
2020-06-04 20:09:35 +02:00
|
|
|
pause: () => {
|
|
|
|
paused = true;
|
|
|
|
},
|
|
|
|
unpause: () => {
|
|
|
|
paused = false;
|
|
|
|
},
|
2016-04-14 21:01:33 +02:00
|
|
|
};
|