Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created July 26, 2018 09:11
Show Gist options
  • Save andreasvirkus/fd21a818a5210023efc3c2f457a0776c to your computer and use it in GitHub Desktop.
Save andreasvirkus/fd21a818a5210023efc3c2f457a0776c to your computer and use it in GitHub Desktop.
export default () => {
const styleEl = document.createElement('style')
document.head.appendChild(styleEl)
// Inject outline preventing styles only for non-keyboard users
document.addEventListener('mousedown', function () {
styleEl.innerHTML = 'a,a:focus,button,button:focus,input,input:focus,textarea,textarea:focus,div:focus {outline:none}'
})
document.addEventListener('keydown', function () {
styleEl.innerHTML = ''
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment