-
-
Save fregante/ffb6a3fe8303f9330e95 to your computer and use it in GitHub Desktop.
Doc strange outline love (jQuery-free)
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
//detecting tab key press | |
document.body.addEventListener('keydown', function detector (e) { | |
var keyCode = e.keyCode || e.which; | |
if(keyCode == 9) { | |
console.log( 'Tab detected' ); | |
document.documentElement.className += ' is-keyboarduser'; | |
document.body.removeEventListener('keydown', detector); | |
} | |
}); |
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
.outline() { | |
outline: none; | |
.is-keyboarduser & { | |
outline: 2px dotted #000; | |
outline-offset: 0.5rem; | |
} | |
} |
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
.tab-link { | |
&:focus { | |
.outline(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a jQuery-free version: https://gist.github.com/dominikwilkowski/b2b4a766030891b0622e