Handle keydown event for input text field - Javascript DOM

Javascript examples for DOM:Key Event

Description

Handle keydown event for input text field

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
function keypressed(form) {
  text = form.textbox.value
  //do any processing on text desired
  preview.innerHTML = text;//from ww w  .  j av a2 s .  c  o m
}

      </script> 
   </head> 
   <body> 
      <form name="myform" action="test.cgi"> 
         <input type="text" id="textbox" name="textbox" onkeydown="keypressed(this.form);"> 
         <input type="submit" value="submit"> 
      </form> 
      <br> 
      <br> 
      <div id="preview"> 
      </div>  
   </body>
</html>

Related Tutorials