Skip to content

Instantly share code, notes, and snippets.

@LucaRosaldi
Forked from davidgilbertson/user-tabbing-class.js
Last active November 7, 2017 11:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucaRosaldi/150d765c479ecb8a88b167db15bbf464 to your computer and use it in GitHub Desktop.
Save LucaRosaldi/150d765c479ecb8a88b167db15bbf464 to your computer and use it in GitHub Desktop.
JS-CSS: Remove Outline on Focus (accessible)
html:not(.no-js):not(.user-is-tabbing) button:focus,
html:not(.no-js):not(.user-is-tabbing) input:focus,
html:not(.no-js):not(.user-is-tabbing) select:focus,
html:not(.no-js):not(.user-is-tabbing) textarea:focus {
outline: none;
}
var addUserTabbingClass = function( event ) {
if ( event.keyCode === 9 ) { // tab key
document.documentElement.classList.add( 'user-is-tabbing' );
window.removeEventListener( 'keydown', addUserTabbingClass );
}
}
window.addEventListener( 'keydown', addUserTabbingClass );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment