Freelance Writing Jobs | Today's Articles | Sign In

 
Browse Sections

Capturing Keys - Part I



<html>
<head>
<script language="JavaScript1.2">
function keyPressed(evt) {
   var F2 = 113;
   if (evt.which == F2) {
      var strMessage = "Hello, there. I will help you";
      strMessage += " in understanding various parts of this page.";

      var strWindowProperties = "toolbar=no,location=no,status=no,";
      strWindowProperties += "menubar=no,scrollbars=no,resizable=yes,";
      strWindowProperties += "width=160,height=20";

      var win = window.open (win, 'window', strWindowProperties);
      win.document.write (strMessage);
   }
}

window.captureEvents (Event.KEYDOWN);
window.onkeydown=keyPressed;
</script>
</head>

<body>
Hello this is the page. You can press F2 key anytime to get help.
</body>
</html>


Note: JavaScript (for Netscape) is case sensitive.



Last Words:

We have yet to see a single function that works for both Netscape and Internet Explorer. Leave it for the next week. See ya.

The copyright of the article Capturing Keys - Part I in JavaScript is owned by Muhammad Ali Shah. Permission to republish Capturing Keys - Part I in print or online must be granted by the author in writing.

Go To Page: 1 2

Articles in this Topic    Discussions in this Topic