how to check if enter is pressed javascript
snippet in javascript

how to check if enter is pressed javascript

user5488

$('#usersearch').keydown(function(e){
    if(e.keyCode === 13){
            alert("Enter was pressed ");
     }  
});

javascript detect enter press on input

user9822

var el = document.getElementById("myInputID");
el.addEventListener("keyup", function(event) {
    if (event.key === "Enter") {
        // Enter key was hit
    }
});