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

310
Views
Noob question; Is it possible to add smooth-scroll effect after keypress event on a page?

I tried smooth-scrolling across a page with the click event and it works, also with CSS, but I tried it with keypress event but the smooth-scrolling doesn't seem to work. Here's my code-snippet;

<body>
  <div class="first-section">
  </div>
  <div id="second-section" class="second-section">
  </div>
</body>
document.addEventListener('keydown', function(e) {
  if (e.key === "ArrowDown") {
    document.querySelector('.second-section').scrollIntoView({
      behavior: 'smooth'
    });
  }
})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Found the problem, had to add the e.preventdefault(); method to prevent the default behavior which is a straight jump to the specified section. Then the smooth scroll will come into place.

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!