From e33f350a1ef0d4526099162e5c62d2e84d58e134 Mon Sep 17 00:00:00 2001 From: Owen Date: Thu, 8 Mar 2018 12:51:55 -0500 Subject: [PATCH] Event listener to prevent page scroll on key press added --- html/game.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/html/game.js b/html/game.js index 4a4b2ad..1207118 100644 --- a/html/game.js +++ b/html/game.js @@ -131,6 +131,12 @@ window.addEventListener("beforeunload", (e) => { leaveGame(); }); +window.addEventListener("keydown", (e) => { + if(e.which == RIGHT_ARROW || e.which == LEFT_ARROW || e.which == UP_ARROW || e.which == DOWN_ARROW){ + e.preventDefault(); + } +}); + function printSpectators(names){ var spectators = names; console.log(spectators);