diff --git a/frontend projects/To-do-list/To-do-list.js b/frontend projects/To-do-list/To-do-list.js index 2c0cc0c2d3..b1982ed90f 100644 --- a/frontend projects/To-do-list/To-do-list.js +++ b/frontend projects/To-do-list/To-do-list.js @@ -6,7 +6,14 @@ const allTaskList = document.querySelector('.all-task') const completed_task = document.querySelector('.completed-task'); const completed_task_heading = document.querySelector('.completed-task-heading') -btn.onclick= function() { +btn.addEventListener("click", myFunction); +window.addEventListener("keypress",function(event){ + if(event.key === "Enter"){ + myFunction(); + } +}); + +function myFunction() { const typedValue =task.value; if(typedValue!==''){ @@ -91,5 +98,4 @@ btn.onclick= function() { } -}; - +}; \ No newline at end of file