mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-09 18:02:50 +01:00
25 lines
529 B
JavaScript
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;
|
|
}
|
|
}
|
|
};
|
|
|