// You can use window.addEventListener or document.addEventListener
window.addEventListener("keydown", function(event) {
if (event.key == "key Name"){
// Do Stuff
}
});
document.addEventListener("keypress", function(event) {
// do stuff
});
$(this).keypress((e) => {
if (e.key === "a") alert("you pressed a");
else alert("you pressed " + e.key);
});
function myKeyPress(e){
var keynum;
if(window.event) { // IE
keynum = e.keyCode;
} else if(e.which){ // Netscape/Firefox/Opera
keynum = e.which;
}
alert(String.fromCharCode(keynum));
}