Closed Thread Icon

Topic awaiting preservation: Key code (Page 1 of 1) Pages that link to <a href="" 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>\

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?

Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 10-26-2001 16:22
<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;



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

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):

« BackwardsOnwards »

Show Forum Drop Down Menu