Skip to content

Commit

Permalink
insert on keydown
Browse files Browse the repository at this point in the history
  • Loading branch information
wmpedersen committed Feb 4, 2024
1 parent 413accd commit 54d61d7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions assets/scripts/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var submissionLst = [];
KEYBOARD_EL.innerHTML = `<div id="keyboard-cont">
<div class="first-row">
<button class="keyboard-button boxed" id="q">Q</button>
<button class="keyboard-button boxed" id="q">W</button>
<button class="keyboard-button boxed" id="w">W</button>
<button class="keyboard-button boxed" id="e">E</button>
<button class="keyboard-button boxed" id="r">R</button>
<button class="keyboard-button boxed" id="t">T</button>
Expand Down Expand Up @@ -413,6 +413,7 @@ document.addEventListener("keydown", (e) => {
if (!found || found.length > 1) {
return
} else if (document.querySelector(`#${pressedKey.toLowerCase()}`) && !document.querySelector(`#${pressedKey.toLowerCase()}`).classList.contains("clicked")) {
insertLetter(pressedKey)
document.querySelector(`#${pressedKey.toLowerCase()}`).classList.add("clicked")
return;
} else {
Expand Down Expand Up @@ -440,7 +441,6 @@ document.addEventListener("keyup", (e) => {
if (!found || found.length > 1) {
return
} else {
insertLetter(pressedKey)
document.querySelector(`#${pressedKey.toLowerCase()}`).classList.remove("clicked");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/practice.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ document.addEventListener("keydown", (e) => {
if (!found || found.length > 1) {
return
} else if (document.querySelector(`#${pressedKey.toLowerCase()}`) && !document.querySelector(`#${pressedKey.toLowerCase()}`).classList.contains("clicked")) {
insertLetter(pressedKey)
document.querySelector(`#${pressedKey.toLowerCase()}`).classList.add("clicked")
return;
} else {
Expand Down Expand Up @@ -323,7 +324,6 @@ document.addEventListener("keyup", (e) => {
if (!found || found.length > 1) {
return
} else {
insertLetter(pressedKey)
document.querySelector(`#${pressedKey.toLowerCase()}`).classList.remove("clicked");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/spelloff.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ document.addEventListener("keydown", (e) => {
if (!found || found.length > 1) {
return
} else if (document.querySelector(`#${pressedKey.toLowerCase()}`) && !document.querySelector(`#${pressedKey.toLowerCase()}`).classList.contains("clicked")) {
insertLetter(pressedKey)
document.querySelector(`#${pressedKey.toLowerCase()}`).classList.add("clicked")
return;
} else {
Expand Down Expand Up @@ -306,7 +307,6 @@ document.addEventListener("keyup", (e) => {
if (!found || found.length > 1) {
return
} else {
insertLetter(pressedKey)
document.querySelector(`#${pressedKey.toLowerCase()}`).classList.remove("clicked");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ document.addEventListener("keydown", (e) => {
if (!found || found.length > 1) {
return
} else if (document.querySelector(`#${pressedKey.toLowerCase()}`) && !document.querySelector(`#${pressedKey.toLowerCase()}`).classList.contains("clicked")) {
insertLetter(pressedKey)
document.querySelector(`#${pressedKey.toLowerCase()}`).classList.add("clicked")
return;
} else {
Expand Down Expand Up @@ -297,7 +298,6 @@ document.addEventListener("keyup", (e) => {
if (!found || found.length > 1) {
return
} else {
insertLetter(pressedKey)
document.querySelector(`#${pressedKey.toLowerCase()}`).classList.remove("clicked");
return;
}
Expand Down

0 comments on commit 54d61d7

Please sign in to comment.