Browse Source

enable arrow key navigation

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

18
src/App.vue

@ -51,6 +51,12 @@ export default {
updateRoute () { updateRoute () {
this.$router.push(`/${this.where}/${this.when}`) this.$router.push(`/${this.where}/${this.when}`)
window.localStorage.setItem('where', this.where) 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: { filters: {
@ -65,6 +71,18 @@ export default {
}, },
created () { created () {
this.where = window.localStorage.getItem('where') || 'zentralmensa' 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> </script>

Loading…
Cancel
Save