I want on a key press an alert box will get displayed. It is done. But the problem is I have a textbox inside the page and when I am trying typing inside the textbox then also the alert box is coming.
$(document).ready(function() {
$(document).keydown(function(e) {
if (e.key == "F8") {
alert('Right key pressed');
} else {
alert("Error key pressed")
}
e.preventDefault();
})
});
HTML:
<input type="text" />