check if a key is pressed javascript code example
Example 1: how to check if enter is pressed javascript
$('#usersearch').keydown(function(e){
if(e.keyCode === 13){
alert("Enter was pressed ");
}
});
Example 2: js when key is pressed
document.addEventListener("keypress", function(event) {
// do stuff
});