~pistos/remoteku

5d29064489613351dac63d4c7351dec4cf56133a — Pistos 1 year, 5 months ago 95aa486
Add keyboard shortcuts
1 files changed, 16 insertions(+), 0 deletions(-)

M frontend/src/views/Home.vue
M frontend/src/views/Home.vue => frontend/src/views/Home.vue +16 -0
@@ 44,6 44,8 @@
      <label>
        Type text:
        <input
          @blur="textFieldFocused = false"
          @focus="textFieldFocused = true"
          @keyup.enter="sendLiteral"
          type="text"
          v-model="literalText"


@@ 70,6 72,19 @@ export default {
    const res = await axios.get('/api/discover')
    this.rokuHosts = res.data
    this.discoveringRokus = false

    const self = this
    window.addEventListener('keydown', function (e) {
      if (! self.textFieldFocused) {
        if (e.key === 'ArrowRight') { e.preventDefault(); self.apiPress('right') }
        if (e.key === 'ArrowLeft') { e.preventDefault(); self.apiPress('left') }
        if (e.key === 'ArrowUp') { e.preventDefault(); self.apiPress('up') }
        if (e.key === 'ArrowDown') { e.preventDefault(); self.apiPress('down') }
        if (e.key === 'Enter') { e.preventDefault(); self.apiPress('select') }
        if (e.key === 'Escape') { e.preventDefault(); self.apiPress('back') }
        if (e.key === 'Backspace') { e.preventDefault(); self.apiPress('back') }
      }
    });
  },
  data: function () {
    return {


@@ 77,6 92,7 @@ export default {
      literalText: '',
      rokuHost: null,
      rokuHosts: [],
      textFieldFocused: false,
    }
  },
  methods: {