Browse Source

enable arrow key navigation

vuex
Schneider 7 years ago
parent
commit
22764dc747
  1. 18
      src/App.vue

18
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
}
}
}
}
</script>

Loading…
Cancel
Save