var el = document.getElementById("myInputID");
el.addEventListener("keydown", function(event) {
if (event.key === "Enter") {
// Enter key was hit
}
});
$('#usersearch').keydown(function(e){
if(e.keyCode === 13){
alert("Enter was pressed ");
}
});
$('.container').on('keydown', 'input', function(e) {
if (e.keyCode === 13) {
e.preventDefault();
e.stopImmediatePropagation();
//Do your stuff...
}
});
function handleKey(ev) {
console.log(ev.type.toUpperCase(), ev.target.id, ev.target.value);
let code = ev.keyCode || ev.which;
if (code == 10 || code == 13) {
//return or enter key
handleSend(ev);
}
}