Click to See Complete Forum and Search --> : EnterKey detection


jce_step
04-02-2003, 12:59 PM
Im trying to detect de EnterKey everytime de user presses it.
For that im using this code:

var key = event.keyCode;
if(key == 13)
do something...

It works fine on IE, but on NetScape and other browsers don't work at all.

jce_step

gil davis
04-02-2003, 01:58 PM
For Netscape you have to capture the event.if (navigator.appName == "Netscape") document.captureEvents(Event.KEYDOWN);
document.onkeydown = mykeydown;
function mykeydown(e) {
if (event) // IE
{key = event.keyCode;}
else
{key = e.which;}
}

jce_step
04-03-2003, 04:16 PM
I also want to make this work for other browsers like SAFARI on MAC.
Does that code applies to this Web Browser ?