Closed Thread Icon

Topic awaiting preservation: Key code (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=7904" title="Pages that link to Topic awaiting preservation: Key code (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Key code <span class="small">(Page 1 of 1)</span>\

 
Osaires
Paranoid (IV) Inmate

From: oslo, Norway
Insane since: Aug 2001

posted posted 10-26-2001 14:33

Is it posible to detect when the user press the left key, the right key, the up key or the down key?


lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 10-26-2001 16:22
code:
<html>
<head>
<title> New Document </title>
<script language="JavaScript">
<!--
ie= document.all ? true : false;
function keyDown(e)
{
if (ie)
var ieKey = event.keyCode;

if (ieKey == 39)
{
alert('left key detected');
}

if (ieKey == 37)
{
alert('right key detected');
}
}
document.onkeydown = keyDown;
//-->
</script>
</head>

<body>

</body>
</html>



for netscapethere is a slight difference that i don't know/care how to/to handle.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 10-26-2001 22:27

Read this article for more information about DOM event model (including capturing key presses): http://www.brainjar.com/dhtml/events/default4.asp


« BackwardsOnwards »

Show Forum Drop Down Menu