diff --git a/src/js/plugins/keyboard.js b/src/js/plugins/keyboard.js index 20f473d..52a2768 100644 --- a/src/js/plugins/keyboard.js +++ b/src/js/plugins/keyboard.js @@ -24,22 +24,26 @@ export default class Keyboard { onKeyPress_(event) { let method; - if (event.which === Keys.SPACE) { - method = this.ws_.goNext; - } else { - if (this.ws_.isVertical) { - if (event.which === Keys.DOWN) { - method = this.ws_.goNext; - } else if (event.which === Keys.UP) { - method = this.ws_.goPrev; - } - } else { - if (event.which === Keys.RIGHT) { - method = this.ws_.goNext; - } else if (event.which === Keys.LEFT) { - method = this.ws_.goPrev; - } - } + switch (event.which) { + case Keys.AV_PAGE: + case Keys.SPACE: + method = this.ws_.goNext; + break; + case Keys.RE_PAGE: + method = this.ws_.goPrev; + break; + case Keys.DOWN: + method = this.ws_.isVertical ? this.ws_.goNext : null; + break; + case Keys.UP: + method = this.ws_.isVertical ? this.ws_.goPrev : null; + break; + case Keys.LEFT: + method = !this.ws_.isVertical ? this.ws_.goPrev : null; + break; + case Keys.RIGHT: + method = !this.ws_.isVertical ? this.ws_.goNext : null; + break; } if (method) { diff --git a/src/js/utils/keys.js b/src/js/utils/keys.js index 02c5a4a..628e40d 100644 --- a/src/js/utils/keys.js +++ b/src/js/utils/keys.js @@ -1,6 +1,8 @@ const Keys = { ENTER: 13, SPACE: 32, + RE_PAGE: 33, + AV_PAGE: 34, LEFT: 37, UP: 38, RIGHT: 39,