on escape keypress javascript code example
Example 1: javascript detect escape key
document.addEventListener('keydown', function(event){
if(event.key === "Escape"){
//do something
}
});
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
}
});