Issue #258 : add support for left/right keys + bugfix

This commit is contained in:
jdescottes 2015-11-25 22:50:43 +01:00
parent 3525b318a6
commit 12ac85f0f6
2 changed files with 12 additions and 4 deletions

View File

@ -50,9 +50,10 @@
var shortcut = pskl.app.shortcutService.getShortcutById(shortcutId);
if (shortcutEl.classList.contains(SHORTCUT_EDITING_CLASSNAME)) {
shortcutEl.classList.remove(SHORTCUT_EDITING_CLASSNAME);
pskl.utils.Dom.removeClass(SHORTCUT_EDITING_CLASSNAME);
this.eventTrapInput.blur();
} else if (shortcut.isEditable()) {
pskl.utils.Dom.removeClass(SHORTCUT_EDITING_CLASSNAME);
shortcutEl.classList.add(SHORTCUT_EDITING_CLASSNAME);
this.eventTrapInput.focus();
}
@ -64,11 +65,14 @@
return;
}
var shortcutKeyObject = pskl.service.keyboard.KeyUtils.createKeyFromEvent(evt);
if (!shortcutKeyObject) {
return;
}
var shortcutKeyString = pskl.service.keyboard.KeyUtils.stringify(shortcutKeyObject);
var shortcutId = shortcutEl.dataset.shortcutId;
var shortcut = pskl.app.shortcutService.getShortcutById(shortcutId);
var shortcutKeyObject = pskl.service.keyboard.KeyUtils.createKeyFromEvent(evt);
var shortcutKeyString = pskl.service.keyboard.KeyUtils.stringify(shortcutKeyObject);
pskl.app.shortcutService.updateShortcut(shortcut, shortcutKeyString);
shortcutEl.classList.remove(SHORTCUT_EDITING_CLASSNAME);
@ -147,7 +151,9 @@
if (pskl.utils.UserAgent.isMac) {
key = key.replace('ctrl', 'cmd');
}
key = key.replace(/left/i, '←');
key = key.replace(/up/i, '↑');
key = key.replace(/right/i, '→');
key = key.replace(/down/i, '↓');
key = key.replace(/>/g, '>');
key = key.replace(/</g, '&lt;');

View File

@ -3,7 +3,9 @@
191 : '?',
8 : 'back',
27 : 'esc',
37 : 'left',
38 : 'up',
39 : 'right',
40 : 'down',
46 : 'del',
189 : '-',