I got a custom dropdown element and enabled scrolling on keypress, using tabindex="-1" on the elements combined with focusing the elements:
document.getElementsByClassName(`elem-${hasFocus.value}`)[0].focus();
Problem occurs when the keypress-scroll hits the top/bottom border. Then pressing the keys scrolls the window. The standard behavior is stopped by using evt.preventDefault(). But this also stops the "smooth" scroll behavior using tabindex (It keeps scrolling but just jumps to the list items). Is there a different way preventing the standard window scroll behavior?
I got no reproducable example but a git repo: Dropdown component
The important method is arrowNavigation.
Didn't understood well, but if what you want is to stop the event propagation to the window when using evt.preventDefault() in your handler, you can try evt.stopPropagation()