Javascript examples for DOM:Key Event
In key down event, add content to div according to text input field value
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// www. ja v a 2 s. c om document.getElementById("setter").addEventListener('keydown', function(e){ if(e.keyCode === 13) { var from = this.value; x = document.getElementById("mything"); x.innerHTML = from; } }) } </script> </head> <body> <input id="setter"> <div id="mything"></div> </body> </html>