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

Specific key detection 1

Status
Not open for further replies.

Monkfish

IS-IT--Management
Joined
Oct 11, 2001
Messages
7
Location
GB
I know about the onkeydown commands etc. but can I detect which key has been pressed?

What I want to do is change the picture in a window between ten options selected by pressing keys 0 through 9.

Thanks :)
 
I would try the Javascript forum. They would probably be more informative on this subject. :-)
 
Try this one. Kudos to SeAL for the original script.

Additionaly, the numeric values for 0-9 are 48-57, respectivly.

<script language=&quot;JavaScript&quot;>
<!--
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
function keyDown(e) {
if (ns4) {
if (e.which == &quot;#&quot;)
{
alert(&quot;your img switch code here&quot;);
}
}
if (ie4) {
if (event.keyCode == &quot;#&quot;)
{
alert(&quot;your img switch code here&quot;);
}
}
}
document.onkeydown = keyDown
if (ns4) document.captureEvents(Event.KEYDOWN)
//-->
</SCRIPT>
 
Thanks Bentley22. I'll take this code over to the javascript forum and ask how I might implement it. I've only just started java programming ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top