How to handle Enter Key. I need to build html code which every time user press enter key on a input text tag, following input box must be focused.

Anjan Bacchu

Hi there, Try this code.
<title>Key Test</title>

<script type="text/javascript">
function whichButton() {
alert("got a key = " + event.keyCode);
if (event.keyCode == 13) {
var followingInput = document.getElementById("2");

<body onkeyup="whichButton()">
First name:
<input id="1" type="text" name="fname" value="Mickey" />

Last name:
<input id="2" type="text" name="lname" value="Mouse" />

Important point is that you should handle the onkeyup event at the body level. In my case, I have 2 input text elements. When you are in the 1st text input element and type ENTER key(code = 13), then the focus will be set to the second element.

Good Luck,