try using "window.event.keyCode" or pass the event variable to the function:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Untitled Page</title>
<script type="text/javascript"><!--
function checkForm(e) {
if (e.keyCode == 13) {
alert("You pressed enter - yay!");
}
}
//-->
</script>
</head>
<body bgcolor="#ffffff">
<input type="text" onkeydown="checkForm(event); return false;">
</body>
</html>
Here is a good page on how different browsers hand the event object: Javascript - Event accessing
Last edited by funkdaddu; 08-10-2006 at 11:33 PM..
|