August 1999
Intermediate to advanced
1488 pages
72h 53m
English
document.onKeyPress
The onKeyPress event handler specifies what should happen when any key is pressed when the Document object is in focus.
In Listing 7.149, the script in the <head> of the document specifies a function to handle all KeyPress events in the document. To be able to do this, the document's captureEvents() method is used to capture all events of type Event.KEYPRESS. When any key is pressed within the page, the document's event handler generates an alert box notifying the user of the event.
<html> <head> <script language="JavaScript1.2"> <!-- Hide // Tell the browser ... |
Read now
Unlock full access