JSFiddle - React, Tailwind, and code Playground

by Matthew Watzman

HTML

<form>
  First name:
  <input type="text" name="firstname">
  <br> Last name:
  <input type="text" name="lastname">
  <input type="hidden" name="hidden">
</form>

JavaScript

$(function() {
  $(':input').on('keydown', function(e) {
    tabE(this, e.originalEvent);
  });
});

function tabE(obj, e) {
  var e = (typeof event != 'undefined') ? window.event : e; // IE : Moz

  var self = $(obj),
    form = self.parents('form:eq(0)'),
    focusable, next;

  if (e.keyCode == 13) {
    focusable = form.find('input,a,select,button,textarea').filter(':visible');
    next = focusable.eq(focusable.index(obj) + 1);
    if (!next.length) {
      next = focusable.first();
    }
    next.focus();
    return false;
  }
}