Created
September 26, 2018 20:53
-
-
Save CharlesInteractive/310d87e3bae2a7c98e49db783ac6491a to your computer and use it in GitHub Desktop.
Only Show Focus Outline While Tabbing
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
body:not(.user-is-tabbing) { | |
* { | |
outline: none; | |
} | |
} |
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 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