Forum Moderators: open

Message Too Old, No Replies

Capturing 'Enter' keypress

return !(window.event && window.event.keyCode == 13)

         

Alternative Future

10:45 am on Feb 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello all,

I have a query regarding window event when the user presses the enter key. We are currently developing an application used only in IE5.5+; there are many forms in the app. to which we would like to ignore a user pressing enter without having to code each page again. It is designed in struts tiles therefore we have a main template that we can use to capture this event taking place. My query is how can we capture this event without first having to call on a function? This would be like a global event used in all pages.

TIA,

-George

SpaceFrog

2:22 pm on Feb 7, 2005 (gmt 0)

10+ Year Member



<script type='text/javascript'>
function keypressed(){
if(event.keyCode=='13'){alert('you pressed enter');}
}
</script>
</head>
<body onload="document.body.focus()" onkeyup="keypressed()">
</body>
</html>