Skip to content

Instantly share code, notes, and snippets.

@chrisirhc
Created March 14, 2021 21:55
Show Gist options
  • Save chrisirhc/2ae15a9c9e25cb2db8a274824614053e to your computer and use it in GitHub Desktop.
Save chrisirhc/2ae15a9c9e25cb2db8a274824614053e to your computer and use it in GitHub Desktop.
Next Tab Keystroke goes to next input
function nextFocusInput(e) {
if (e.target.tagName == 'INPUT') {
return;
}
if (!e.relatedTarget || e.relatedTarget.tagName != 'INPUT') {
return;
}
e.preventDefault();
var allInputs = Array.from(document.querySelectorAll('input'));
allInputs[allInputs.indexOf(e.relatedTarget) + 1].focus();
}
document.addEventListener('focusin', nextFocusInput);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment