on input enter javascript event code example
Example 1: javascript enter event listener
document.querySelector('#txtSearch').addEventListener('keypress', function (e) {
if (e.key === 'Enter') {
// code for enter
}
});
Example 2: javascript detect enter press on input
var el = document.getElementById("myInputID");
el.addEventListener("keyup", function(event) {
if (event.key === "Enter") {
// Enter key was hit
}
});