Hi,

I found a cross-browser (IE and Firefox) method on www.javaranch.com
(which is down at the moment).

1) Dispense with onkeydown in body and use document.onkeydown instead.

2) Then in the key-handling script...declare evt as a parameter.

3) Then populate nbr with event.keyCode if window.event is not false
(which it is in Firefox) OTHERWISE use evt.which.

Hey presto keypresses can be caught in IE and Firefox.

But is this a "standards" acceptable way of doing it?

<HTML>
   <script>
      function handleKeyPress(evt) {
         var nbr;
         var nbr = (window.event)?event.keyCode:evt.which;
        alert(nbr);
        return true;
     }
    document.onkeydown= handleKeyPress;
</script>

   <BODY>
      <p>Keypress7</p>
   </BODY>
</HTML>

Cheers,

Simon


*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************

Reply via email to