Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <html>
  2. <body>
  3. <script language="JavaScript">
  4. function onLoad() {
  5. console.log(document.getElementById("test"));
  6. document.getElementById("test").onkeydown = function(event) {
  7. console.log("Code: "+event.keyCode+"; Key: "+String.fromCharCode(event.keyCode));
  8. }
  9. }
  10. </script>
  11. <body onLoad="onLoad();">
  12. <input id="test">
  13. </body>
  14. </html>
  15.  
  16. document.onkeypress = function(evt) {
  17. evt = evt || window.event;
  18. var charCode = evt.which || evt.keyCode;
  19. var charTyped = String.fromCharCode(charCode);
  20. alert("Character typed: " + charTyped);
  21. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement