Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

306
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda