diff options
-rw-r--r-- | html/cards/script.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/html/cards/script.js b/html/cards/script.js index 0f2c99a..9d76e24 100644 --- a/html/cards/script.js +++ b/html/cards/script.js @@ -120,6 +120,13 @@ const initializeGame = () => { // Add event listeners canvas.addEventListener('mousedown', handleMouseDown); canvas.addEventListener('contextmenu', e => e.preventDefault()); + + // Add event listener for the 'r' key + document.addEventListener('keydown', e => { + if (e.key === 'r') { + handleResetGame(); + } + }); }; // Event handlers @@ -189,6 +196,13 @@ const handleMouseDown = e => { } }; +// Add this function to handle the reset confirmation +const handleResetGame = () => { + if (confirm("Would you like to reset the cards?")) { + initializeGame(); // Reset the game state + } +}; + // Start the game initializeGame(); |