Use onkeypress In JavaScript to Display Alerts

By using JavaScript, we can display alert box when user press on the text box.

<!DOCTYPE html>
<p><b>OnKeyDown JavaScript Example<b></p>
<input type="text"  id="txtKey"onkeydown="onKeyDown()">
function onKeyDown() {
alert("You press the down arrow key in the text box");

Leave a Reply

Your email address will not be published. Required fields are marked *