Skip to content

Commit

Permalink
Added Enter support for start the timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Palm1ye committed May 4, 2024
1 parent 97fd522 commit d98b070
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d98b070

Please sign in to comment.