add event enter js code example
Example 1: javascript enter event listener
document.querySelector('#txtSearch').addEventListener('keypress', function (e) {
if (e.key === 'Enter') {
// code for enter
}
});
Example 2: evento tecla enter javascript
$(document).keypress(function(e) {
if(e.which == 13) {
alert('You pressed enter!');
}
});