<html> <script src="http://www.google.com/jsapi"></script><script>google.load("jquery", "1");</script> <script> $(function(){ $(document).keyup(function(e){ if (e.keyCode == 13 && e.shiftKey == false) { $(document.activeElement).nextAll("input:first").focus(); } else if (e.keyCode == 13 && e.shiftKey == true) { $(document.activeElement).prevAll("input:first").focus(); } }); }); </script> <body> <span>sample 1:</span><input type="text"><br> <span>sample 2:</span><input type="text"><br> <span>sample 3:</span><input type="text"><br> <span>sample 4:</span><input type="text"><br> <span>sample 5:</span><input type="text"><br>