Use onkeypress In JavaScript to Display Alerts
By using JavaScript, we can display alert box when user press on the text box.
<!DOCTYPE html>
<html>
<body>
<p><b>OnKeyDown JavaScript Example<b></p>
<input type="text" id="txtKey"onkeydown="onKeyDown()">
<script>
function onKeyDown() {
alert("You press the down arrow key in the text box");
}
</script>
</body>
</html>