Zeblue commited on
Commit
f8407ec
·
verified ·
1 Parent(s): e33392e

make the game start by pressing space

Browse files
Files changed (1) hide show
  1. index.html +8 -2
index.html CHANGED
@@ -255,12 +255,18 @@
255
  handleJump();
256
  }
257
  });
258
-
259
  startBtn.addEventListener('click', startGame);
260
  restartBtn.addEventListener('click', startGame);
261
 
 
 
 
 
 
 
 
262
  // Initialize feather icons
263
- feather.replace();
264
  });
265
  </script>
266
  </body>
 
255
  handleJump();
256
  }
257
  });
 
258
  startBtn.addEventListener('click', startGame);
259
  restartBtn.addEventListener('click', startGame);
260
 
261
+ // Start game with spacebar
262
+ document.addEventListener('keydown', (e) => {
263
+ if (e.code === 'Space' && startScreen.style.display !== 'none') {
264
+ startGame();
265
+ }
266
+ });
267
+
268
  // Initialize feather icons
269
+ feather.replace();
270
  });
271
  </script>
272
  </body>