From 440e1bf37e0d72664c5e81ac66945399b54a1637 Mon Sep 17 00:00:00 2001 From: Antonio Laguna Date: Thu, 2 Mar 2017 09:41:59 +0100 Subject: [PATCH] Allowing navigation with Home and End keys Fixes #49 --- src/js/plugins/keyboard.js | 11 ++++++++++- src/js/utils/keys.js | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/js/plugins/keyboard.js b/src/js/plugins/keyboard.js index 52a2768..ce199f5 100644 --- a/src/js/plugins/keyboard.js +++ b/src/js/plugins/keyboard.js @@ -23,6 +23,7 @@ export default class Keyboard { */ onKeyPress_(event) { let method; + let argument; switch (event.which) { case Keys.AV_PAGE: @@ -32,6 +33,14 @@ export default class Keyboard { case Keys.RE_PAGE: method = this.ws_.goPrev; break; + case Keys.HOME: + method = this.ws_.goToSlide; + argument = 0; + break; + case Keys.END: + method = this.ws_.goToSlide; + argument = this.ws_.maxSlide_ - 1; + break; case Keys.DOWN: method = this.ws_.isVertical ? this.ws_.goNext : null; break; @@ -47,7 +56,7 @@ export default class Keyboard { } if (method) { - method.call(this.ws_); + method.call(this.ws_, argument); } } } diff --git a/src/js/utils/keys.js b/src/js/utils/keys.js index 628e40d..2a6041f 100644 --- a/src/js/utils/keys.js +++ b/src/js/utils/keys.js @@ -3,6 +3,8 @@ const Keys = { SPACE: 32, RE_PAGE: 33, AV_PAGE: 34, + END: 35, + HOME: 36, LEFT: 37, UP: 38, RIGHT: 39,