diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-11-18 22:14:33 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-18 22:14:33 +0900 |
commit | bdae21b3a15231a2b107a1d1bdf5023e32c3a895 (patch) | |
tree | 6f2a5c8f0e1109e45027aeae58b3b3d7c1fd0e3e /src/console/components | |
parent | 780373922711eba64745f0f3c1d217349a49263e (diff) | |
parent | 5d0554c7e8be7d2e96a76927b46a37c82e0eb011 (diff) |
Merge pull request #162 from heavenshell/feature/console_key
Add c-n, c-j, c-p, c-k, c-m to console keybind
Diffstat (limited to 'src/console/components')
-rw-r--r-- | src/console/components/console.js | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/console/components/console.js b/src/console/components/console.js index 7bc3364..7c23dab 100644 --- a/src/console/components/console.js +++ b/src/console/components/console.js @@ -31,14 +31,30 @@ export default class ConsoleComponent { } } + doEnter(e) { + e.stopPropagation(); + e.preventDefault(); + return this.onEntered(e.target.value); + } + + selectNext(e) { + this.store.dispatch(consoleActions.completionNext()); + e.stopPropagation(); + e.preventDefault(); + } + + selectPrev(e) { + this.store.dispatch(consoleActions.completionPrev()); + e.stopPropagation(); + e.preventDefault(); + } + onKeyDown(e) { switch (e.keyCode) { case KeyboardEvent.DOM_VK_ESCAPE: return this.hideCommand(); case KeyboardEvent.DOM_VK_RETURN: - e.stopPropagation(); - e.preventDefault(); - return this.onEntered(e.target.value); + return this.doEnter(e); case KeyboardEvent.DOM_VK_TAB: if (e.shiftKey) { this.store.dispatch(consoleActions.completionPrev()); @@ -48,6 +64,26 @@ export default class ConsoleComponent { e.stopPropagation(); e.preventDefault(); break; + case KeyboardEvent.DOM_VK_OPEN_BRACKET: + if (e.ctrlKey) { + return this.hideCommand(); + } + break; + case KeyboardEvent.DOM_VK_M: + if (e.ctrlKey) { + return this.doEnter(e); + } + break; + case KeyboardEvent.DOM_VK_N: + if (e.ctrlKey) { + this.selectNext(e); + } + break; + case KeyboardEvent.DOM_VK_P: + if (e.ctrlKey) { + this.selectPrev(e); + } + break; } } |