Detecting focus hack

Kevin Kim
1 min readNov 12, 2019

Load up the site, then open up the console, then just paste in the following code:

document.body.addEventListener('focusin', (event) => {  console.log(document.activeElement)})

Now when you tab, the console should log what element the app is focused in at.

Great for detecting things like if people wrote outline: 0 in the css code, or something wonky is happening where things aren’t tabbing over to the right thing.

Source:

--

--