Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
Stop scrolling window element on keypress

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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()

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!