Javascript examples for DOM HTML Element:Form Event
Add key up action handler to input box
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w. ja v a 2 s .com var input = document.getElementById("name"); input.onkeyup = function(e){ if(e.keyCode == 32) console.log("Translate"); // Your translation code }; } </script> </head> <body> <input id="name" placeholder="Name"> </body> </html>