Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p>Press the "O" key on the keyboard in the input field to alert some text.</p>

<input type="text" size="40" onkeypress="myFunction(event)">

<p id="demo"></p>

<script>
function myFunction(event) {
    var x = event.charCode || event.keyCode;
    if (x == 111 || x == 79) {  // o is 111, O is 79
        alert("You pressed the 'O' key!");
    }
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy