I would like my function to execute while pressing the submit button (that already exists) or on pressing the enter key in either of any of the 3 inputs (Id's: taskInfo, dueDate, dueTime).
I've tried separating the function and doing it that way but it did not work at all..
function init() {
window.notes = getLocalStorage('notes') || [];
setNotesUi();
// make note with form inputs by using button +reset notes+ set localStorage
var submitElement = document.getElementById('submit');
submitElement.addEventListener('click', function ()
Gonna need the following function to execute while pressing enter either anywhere or while specifically on 3 inputs called (taskInfo, dueDate, dueTime) just like here it works with a mouse click only on the submit button
{
var taskInfoElement = document.getElementById('taskInfo');
var dueDateElement = document.getElementById('dueDate');
var dueTimeElement = document.getElementById('dueTime');
var note = {
taskInfo: taskInfoElement.value,
dueDate: dueDateElement.value,
dueTime: dueTimeElement.value
};
notes.push(note);
setNotesUi();
setLocalStorage('notes', notes);
});
}
Gonna need the following function to execute while pressing enter either anywhere or while specifically on 3 inputs called (taskInfo, dueDate, dueTime) just like here it works with a mouse click only on the submit button