summaryrefslogtreecommitdiff
path: root/src/components/Keyboard.vue
blob: 7d76dbd08e04feb0e4ae24b2c1cd7670f16b3416 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<template>
  <table>
    <tr v-for="letters in rows" :key="letters">
      <td v-for="letter in letters" :key="letter">
        <KeyboardKey
          :letter="letter"
          :buttonPressed="pressButton"
        ></KeyboardKey>
      </td>
    </tr>
  </table>
</template>

<script setup lang="ts">
import KeyboardKey from "@/components/KeyboardKey.vue";

let props = defineProps<{
  addLetter: (letter: string) => void;
  removeLetter: () => void;
  navigate: (direction: "left" | "right" | "first" | "last") => void;
}>();

const rows = ["QWERTZUIOPÜ", "ASDFGHJKLÖÄ", "YXCVBNMß"];

function pressButton(letter: string) {
  if (rows.join("").indexOf(letter) > -1) {
    props.addLetter(letter);
  } else {
    console.log("button " + letter + " pressed");
  }
}
</script>

<style scoped></style>