<input> <script> inp = document.getElementsByTagName("input")[0]; inp.focus(); document.onkeydown = function(event){ inp.value = String.fromCharCode( (event=event||window.event).keyCode||event.charCode ||event.which||" err " ); } </script>