Created
March 14, 2021 21:55
-
-
Save chrisirhc/2ae15a9c9e25cb2db8a274824614053e to your computer and use it in GitHub Desktop.
Next Tab Keystroke goes to next input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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