Skip to content

Commit

Permalink
Wpm stop dropping once done
Browse files Browse the repository at this point in the history
  • Loading branch information
Grivel-l committed Jul 8, 2019
1 parent e3ce6e3 commit 6a067ea
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ inputField.addEventListener('keydown', e => {

// If it is the first character entered
if (currentWord === 0 && inputField.value === '' && e.key >= '!' && e.key <= '~' && e.key.length === 1) {
if (resultTimeout !== null) {
clearTimeout(resultTimeout);
}
(function printResult() {
if (realTime) {
showResult();
Expand Down Expand Up @@ -168,12 +171,7 @@ inputField.addEventListener('keydown', e => {
}

if (wordList[currentWord] !== undefined) {
if (e.key === "Backspace") {
if (inputField.value.length > 0 &&
inputField.value[inputField.value.length - 1] === wordList[currentWord][inputField.value.length - 1]) {
correctKeys -= 1;
}
} else if (e.key >= "!" && e.key <= "~") {
if (e.key >= "!" && e.key <= "~") {
const word = `${inputField.value}${e.key}`;
if (word[word.length - 1] === wordList[currentWord][word.length - 1]) {
correctKeys += 1;
Expand Down

0 comments on commit 6a067ea

Please sign in to comment.