Navigating through text input fields using arrow keys and return
<p>I'm trying to build a simple navigation mechanism between multiple input fields using jQuery. The first part of the code, skipping down by using the down arrow or return key work fine, but when I added the second block to go backwards by looking for the up arrow and then reversing the order, typing in the first text field jumps right away to the second. Any thoughts?</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function(){
    // get only input tags with class data-entry
    textboxes = $("input.data-entry");
    // now we check to see which browser is being used
    if ($.browser.mozilla) {
        $(textboxes).keypress (checkForAction);
    } else {
        $(textboxes).keydown (checkForAction);
    }
});

function checkForAction (event) {
    if (event.keyCode == 13 || 40) {
          currentBoxNumber = textboxes.index(this);
        if (textboxes[currentBoxNumber + 1] != null) {
            nextBox = textboxes[currentBoxNumber + 1]
            nextBox.focus();
            nextBox.select();
            event.preventDefault();
            return false;
        }
    }
    if (event.keyCode == 38) {
          currentBoxNumber = textboxes.index(this);
        if (textboxes[currentBoxNumber - 1] != null) {
            prevBox = textboxes[currentBoxNumber - 1]
            prevBox.focus();
            prevBox.select();
            event.preventDefault();
            return false;
        }
    }
}
&lt;/script&gt;
</code></pre>
