Where did you find the line:
document.captureEvents(Event.KEYPRESS);
I think it's completely bogus. Remove it, and everything works just fine.
Cheers,
Anil
----- Original Message -----
From: "Mark Irvine" <mark@m...>
To: "javascript" <javascript@p...>
Sent: Tuesday, April 24, 2001 2:40 PM
Subject: [javascript] Capture Events
> Hi there,
>
> I have been trying to capture certian keystrokes made by the user, namely
> the return key for form submission. Located below is the code I intend to
> use, at the moment it simply alerts back the keystroke - however it does
> not appear to work. I get an error message saying that 'Event' is
> undefined? Just for the record I am using IE5.5 and have placed the code
> in the body part of the document.
>
> <script language="JavaScript1.2">
> function blockA(e)
> {
> var keyChar = String.fromCharCode(window.event.keyCode);
> alert(keyChar);
> }
> document.captureEvents(Event.KEYPRESS);
> document.onkeypress = blockA;
> </script>
>
> Hope someone can help,
>
> Mark