szurubooru/public_html/js/Keyboard.js
Marcin Kurczewski 3f93aaa652 Updated mousetrap to newest version
This removes need for my fix in keyboard.js: ccampbell/mousetrap#53
2014-10-18 18:54:12 +02:00

32 lines
519 B
JavaScript

var App = App || {};
App.Keyboard = function(mousetrap) {
function keyup(key, callback) {
unbind(key);
mousetrap.bind(key, callback, 'keyup');
}
function keydown(key, callback) {
unbind(key);
mousetrap.bind(key, callback);
}
function reset() {
mousetrap.reset();
}
function unbind(key) {
mousetrap.unbind(key, 'keyup');
mousetrap.unbind(key);
}
return {
keydown: keydown,
keyup: keyup,
reset: reset,
unbind: unbind,
};
};
App.DI.register('keyboard', ['mousetrap'], App.Keyboard);