Skip to content

Commit

Permalink
Fixed Issue kubowania#5 Keycode-Deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
mboeder-2306 committed Jun 1, 2023
1 parent 3f96f06 commit 155cbe1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ document.addEventListener('DOMContentLoaded', () => {
function control(e) {
squares[currentIndex].classList.remove('snake')

if(e.keyCode === 39) {
if(e.code === "ArrowRight") {
direction = 1 //if we press the right arrow on our keyboard, the snake will go right one
} else if (e.keyCode === 38) {
} else if (e.code === "ArrowUp") {
direction = -width // if we press the up arrow, the snake will go back ten divs, appearing to go up
} else if (e.keyCode === 37) {
} else if (e.code === "ArrowLeft") {
direction = -1 // if we press left, the snake will go left one div
} else if (e.keyCode === 40) {
} else if (e.code === "ArrowDown") {
direction = +width //if we press down, the snake head will instantly appear in the div ten divs from where you are now
}
}
Expand Down

0 comments on commit 155cbe1

Please sign in to comment.