Javascript examples for DOM:Key Event
Dispatching a key event with preventDefault
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/*from w w w.java2 s .co m*/ document.getElementById("foo").addEventListener("keypress", function(event) { if (event.keyCode === 65) { document.getElementById("foo").value += String.fromCharCode(1740); event.preventDefault(); } }, false); }); </script> </head> <body> <input id="foo" value=""> </body> </html>