diff --git a/src/App.vue b/src/App.vue index 9ed555e3..f946a5db 100644 --- a/src/App.vue +++ b/src/App.vue @@ -14,10 +14,19 @@ const word: Word = $computed(() => { return wordList[chapterIndex][wordIndex] }) let input = $ref('') +let wrong = $ref('') function onKeyDown(e: KeyboardEvent) { if (e.keyCode >= 65 && e.keyCode <= 90) { - input += e.key.toLowerCase() + let letter = e.key.toLowerCase() + if (input + letter === word.name.slice(0, input.length + 1)) { + input += letter + } else { + wrong = letter + setTimeout(() => { + wrong = input = '' + }, 1000) + } } } @@ -52,8 +61,9 @@ function playAudio() {