mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-25 01:45:26 +01:00
#63 fix missing jwerty dependency issue
This commit is contained in:
parent
eb4408e0a1
commit
f601cacb80
2 changed files with 8 additions and 24 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue