[Javascript] Re: Re: Is this right Javascript?

Hassan Schroeder hassan at webtuitive.com
Wed Apr 9 13:46:48 CDT 2003


Rodney Myers wrote:

> However the Pure Javascript example still did NOT work and gave the same 
> error.

>>> <script type="text/javascript" language="JavaScript1.2">
>>> <!--
>>>
>>> // Tell the browser you want to intercept ALL key press events
>>> // on the page and then define a function to handle them.
>>> document.captureEvents(Event.KEYPRESS);
>>> document.onKeyPress = myKeyPressHandler;

document.onkeypress -- not CamelCased  -- works in NS4 and Moz,
though not IE ...

>>> // Define the myKeyPressHandler function to handle
>>> // key press events.
>>> function myKeyPressHandler(e){
>>>  alert("A key press event took place within the document!");
>>> }
>>>
>>> // -->
>>> </script>
>>> </head>
>>> <body>
>>> Anytime you press a key within this document, you will
>>> get a message alerting you that a KeyPress event has taken place.
>>> </body>

-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the Javascript mailing list