jsketcher/web/app/sketcher/input-manager.js
2016-11-24 02:32:10 -08:00

25 lines
529 B
JavaScript

import {keymap} from './keymaps/default'
import {jwerty} from 'jwerty'
export function InputManager(app) {
this.app = app;
this.keymap = keymap;
$(() => {
$(document)
.on('keydown', (e) => this.handleKeyPress(e))
});
}
InputManager.prototype.handleKeyPress = function(e) {
switch (e.keyCode) {
//case 27 : this.clear(); break;
}
for (let action in this.keymap) {
if (jwerty.is(this.keymap[action], e)) {
setTimeout(() => this.app.actions[action].action(e), 0);
break;
}
}
};