From 155cbe1116a8c1d7c0ffc6e84c0ba6581e3982db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20B=C3=B6der?= Date: Thu, 1 Jun 2023 22:10:06 +0200 Subject: [PATCH] Fixed Issue #5 Keycode-Deprecation --- app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 7277ecb..609eb06 100644 --- a/app.js +++ b/app.js @@ -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 } }