Focus next element on keypress
The input elements are all siblings of each other, so you can use $.next() to select the next one that appears after the event target.  There is no need to name each input individually.



$(':input').keypress(function() {
    $(this).next(':input').focus();
});
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;input placeholder="1"&gt;
&lt;input placeholder="2"&gt;
&lt;input placeholder="3"&gt;
&lt;input placeholder="4"&gt;
&lt;input placeholder="5"&gt;