#63 fix missing jwerty dependency issue

This commit is contained in:
Val Erastov 2019-01-16 17:48:12 -08:00
parent eb4408e0a1
commit f601cacb80
2 changed files with 8 additions and 24 deletions

View file

@ -1,27 +1,11 @@
import {keymap} from './keymaps/default'
import {jwerty} from 'jwerty'
import Mousetrap from 'mousetrap';
export function InputManager(app) {
this.app = app;
this.keymap = keymap;
$(() => {
$(document)
.on('keydown', (e) => this.handleKeyPress(e))
});
for (let action of Object.keys(keymap)) {
Mousetrap.bind(keymap[action], e => this.app.actions[action].action(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);
e.stopPropagation();
e.preventDefault();
break;
}
}
};

View file

@ -1,7 +1,7 @@
export const keymap = {
'save': 'ctrl+S',
'open': 'ctrl+O',
'new' : 'ctrl+N',
'save': 'ctrl+s',
'open': 'ctrl+o',
'new' : 'ctrl+n',
'terminal': '`',
'info': 'F1'
};