gallery.accords-library.com/client/js/util/keyboard.js

34 lines
724 B
JavaScript
Raw Normal View History

'use strict';
const mousetrap = require('mousetrap');
const settings = require('../models/settings.js');
2016-07-22 11:27:52 +00:00
let paused = false;
const _originalStopCallback = mousetrap.prototype.stopCallback;
mousetrap.prototype.stopCallback = function(...args) {
var self = this;
if (paused) {
return true;
}
return _originalStopCallback.call(self, ...args);
};
function bind(hotkey, func) {
if (settings.get().keyboardShortcuts) {
mousetrap.bind(hotkey, func);
return true;
}
return false;
}
function unbind(hotkey) {
mousetrap.unbind(hotkey);
}
module.exports = {
bind: bind,
unbind: unbind,
2016-07-22 11:27:52 +00:00
pause: () => { paused = true; },
unpause: () => { paused = false; },
};