Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onKeyDown Event Applying to Entire Document

Status
Not open for further replies.

Watts

Programmer
Jan 18, 2001
80
US
Here's the situation:

(Code I Have):

<SCRIPT>
document.onKeyDown=handleKey;
document.onKeyUp=releaseKey;

function handleKey() {
// does something
}
function releaseKey() {
// does something
}
</SCRIPT>
<BODY>
<APPLET ---- onKeyDown=&quot;handleKey()&quot; onKeyUp=&quot;releaseKey()&quot;>
</BODY>

My problem is that if I click on the document, it capture the keyEvent correctly, but when I click on the Java Applet, the keyEvent functions are never called. What is going on here? Isn't there a way to capture keyEvents for the entire page no matter what is on it?
 
well, no. your problem is this: the mouse-event and key-press messages are sent from the operating system to the browser and then to the js code (in this case). but when the content includes something such as an applet or embed or iframe, the messages are sent to this specific object. example: if you have an iframe, when the mouse is in the iframe the scripting behaves like the iframe were its own window.

if you wanted to capture the keypress events for the applet, you could either place a transparent div over the top of the applet or intercept the keypress events in the applet and then make the appropiate javascript functions happen through function calls. Robert Carpenter
questions? comments? thanks? email me!
linkemapx@hotmail.com
Icq: 124408594
online.dll

AIM & MSN: robacarp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top