2 ms·
Another technique to mess up keyboard users: don’t use the document scroll area, but make your own (and don’t focus it or anything in JavaScript). Thus the user
by chrismorgan 6y ago
Another technique to mess up keyboard users: don’t use the document scroll area, but make your own (and don’t focus it or anything in JavaScript). Thus the user will have to press Tab or click in the area before keyboard navigation keys will work. So for best results put a large number of focusable elements before the scrollable pane, so that the keyboard user must press Tab a large and unpredictable number of times before it works.
It’ll be something like this:
<body>
<div tabindex=0></div>
<div tabindex=0></div>
<div tabindex=0></div>
<div style="position:absolute;top:0;left:0;right:0;bottom:0;overflow:auto">
…
</div>
</body>
You could probably mess with other tabindexes (randomly jump through the document with Tab!) without Lighthouse baulking.
I was going to suggest adding `pointer-events: none` so that the user can’t just click to focus it, but that was already done!
(I mentioned focusing your scroll area element as something you need to do if you roll your own rather than using the document scroll area; but that’s not all you need to do. You also need to monitor blur events and change any .blur() calls, so as to avoid the document element ever retaining focus. It inherently depends on JavaScript, and is very fiddly to get fully right—I’m actually not sure if anyone gets it fully right; the interactions of focus and selection are nuanced and inconsistent, and it’s extremely easy to mess up accessibility software; I haven’t finished my research on the topic. I strongly recommend against the technique on web pages; web apps can occasionally warrant it.)