One option is to try to catch the tab key press and manually adjust the scroll position, as you suggested, but this approach could result in unexpected outcomes.
A more effective method would be to modify your layout to accommodate the overlay at the bottom.
In essence, all of your primary content should be contained within a specific container (this could be the <main>
element if the bottom overlay is an <aside>
, otherwise, utilize a <div>
).
Adjust the height of that container to be equal to the page height minus the height of the overlay.
This ensures that no content will ever be hidden behind the overlay (which technically ceases to function as an overlay when nothing overlaps it).
The benefit of this approach is that when you reach the very bottom of the page, everything remains visible. With an overlay, there's a risk of some content being partly obscured if you don't allocate sufficient margin or padding at the bottom.