From d98b070ec8b7d5fcb58987ed5742bd92ee375f4f Mon Sep 17 00:00:00 2001 From: Palmiye <64729369+Palm1ye@users.noreply.github.com> Date: Sat, 4 May 2024 20:42:48 +0300 Subject: [PATCH] Added Enter support for start the timer --- script.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/script.js b/script.js index d3f73e6..016827e 100644 --- a/script.js +++ b/script.js @@ -28,6 +28,15 @@ function startTimer(duration) { }, 1000); } +function handleEnterKeyPress(event) { + if (event.key === 'Enter') { + event.preventDefault(); // ignore submit thing + startButton.click(); // simulate click + } +} + +minutesInput.addEventListener('keypress', handleEnterKeyPress); + startButton.addEventListener('click', function () { let minutes = parseInt(minutesInput.value); if(Number.isInteger(minutes) == false) {