Skip to content

Instantly share code, notes, and snippets.

@leMaur
Last active September 5, 2019 07:19
Show Gist options
  • Save leMaur/637fef8846c6914fdee23cff08077933 to your computer and use it in GitHub Desktop.
Save leMaur/637fef8846c6914fdee23cff08077933 to your computer and use it in GitHub Desktop.
(function (window, document) {
'use strict';
let className = 'tabbing';
let handleFirstTab = function (e) {
if (e.keyCode === 9) {
document.body.classList.add(className);
window.removeEventListener('keydown', handleFirstTab);
window.addEventListener('mousedown', handleMouseDownOnce);
}
}
let handleMouseDownOnce = function () {
document.body.classList.remove(className);
window.removeEventListener('mousedown', handleMouseDownOnce);
window.addEventListener('keydown', handleFirstTab);
}
window.addEventListener('keydown', handleFirstTab);
})(window, document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment