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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrieve keycode when <OBJECT onKeyDown="trapKeys()"

Status
Not open for further replies.

almoes

Programmer
Jan 8, 2003
291
US
Hi all!

I want to retrieve the keycode when a key is pressed on my object in my HTML page.
This is what I tried:

<OBJECT ID="RSPcli" CLASSID="CLSID:24B4E4FA-5E05-4800-BBCC-20B8D5F8A811" height=490 Width=979 align="center" onKeyDown="trapKeys()"></OBJECT>

function trapKeys() {
if (document.all.RSPcli.object.event.keyCode==40){
alert("key "+String(document.all.RSPcli.object.event.keyCode))
}
}
</script>

I can't reach the object's event, any ideas of the proper syntax? i know in the case of window its window.event.keyCode, however if the object has the focus its the object trapping the keys.
Thanxs!

Cheers,
Alej
 
I found out the correct syntax for retrieving the keys from the object: self.event.keyCode. However, it fires for every key I press except for the arrows, which I specially need. In the body tag they do fire. Any ideas???? thanxs.

cheers,
alej
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top