summaryrefslogtreecommitdiff
path: root/src/components/Keyboard.vue
blob: 3b428c8e176d30f0ca6b044ed97b37dfab8ec47d (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Ü", "ASDFFGHJKLÖÄ", "YXCVBNMß"];

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

<style scoped></style>