From 22764dc74793cac86906b7cf8b0126e5de3e8614 Mon Sep 17 00:00:00 2001 From: Marcel Schneider Date: Thu, 1 Jun 2017 12:21:43 +0200 Subject: [PATCH] enable arrow key navigation --- src/App.vue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/App.vue b/src/App.vue index e6624b8..5667f24 100644 --- a/src/App.vue +++ b/src/App.vue @@ -51,6 +51,12 @@ export default { updateRoute () { this.$router.push(`/${this.where}/${this.when}`) window.localStorage.setItem('where', this.where) + }, + previousDay () { + this.when === 1 ? this.when = 6 : this.when-- + }, + nextDay () { + this.when === 6 ? this.when = 1 : this.when++ } }, filters: { @@ -65,6 +71,18 @@ export default { }, created () { this.where = window.localStorage.getItem('where') || 'zentralmensa' + let vm = this + document.onkeydown = (evt) => { + evt = evt || window.event + switch (evt.keyCode) { + case 37: + vm.previousDay() + break + case 39: + vm.nextDay() + break + } + } } }