Spaces:
Running
Running
make the game start by pressing space
Browse files- 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 |
-
|
| 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>
|