1
0
mirror of https://github.com/webslides/WebSlides.git synced 2025-08-26 14:34:27 +02:00

Allowing navigation with Home and End keys

Fixes #49
This commit is contained in:
Antonio Laguna
2017-03-02 09:41:59 +01:00
parent 8ae6954e5f
commit 440e1bf37e
2 changed files with 12 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ export default class Keyboard {
*/ */
onKeyPress_(event) { onKeyPress_(event) {
let method; let method;
let argument;
switch (event.which) { switch (event.which) {
case Keys.AV_PAGE: case Keys.AV_PAGE:
@@ -32,6 +33,14 @@ export default class Keyboard {
case Keys.RE_PAGE: case Keys.RE_PAGE:
method = this.ws_.goPrev; method = this.ws_.goPrev;
break; 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: case Keys.DOWN:
method = this.ws_.isVertical ? this.ws_.goNext : null; method = this.ws_.isVertical ? this.ws_.goNext : null;
break; break;
@@ -47,7 +56,7 @@ export default class Keyboard {
} }
if (method) { if (method) {
method.call(this.ws_); method.call(this.ws_, argument);
} }
} }
} }

View File

@@ -3,6 +3,8 @@ const Keys = {
SPACE: 32, SPACE: 32,
RE_PAGE: 33, RE_PAGE: 33,
AV_PAGE: 34, AV_PAGE: 34,
END: 35,
HOME: 36,
LEFT: 37, LEFT: 37,
UP: 38, UP: 38,
RIGHT: 39, RIGHT: 39,