Skip to content

Instantly share code, notes, and snippets.

@davidgilbertson
Last active August 1, 2019 07:57
Show Gist options
  • Save davidgilbertson/1955dc1dde36e1fabbc6178052294560 to your computer and use it in GitHub Desktop.
Save davidgilbertson/1955dc1dde36e1fabbc6178052294560 to your computer and use it in GitHub Desktop.
function handleFirstTab(e) {
if (e.keyCode === 9) {
document.body.classList.add('user-is-tabbing');
window.removeEventListener('keydown', handleFirstTab);
window.addEventListener('mousedown', handleMouseDownOnce);
}
}
function handleMouseDownOnce() {
document.body.classList.remove('user-is-tabbing');
window.removeEventListener('mousedown', handleMouseDownOnce);
window.addEventListener('keydown', handleFirstTab);
}
window.addEventListener('keydown', handleFirstTab);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment