Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
Event handler does not work properly in react

I have this code in HomePage component and when pressing arrow down/up key, nothing happens. And I just realized that eventhandler works properly when pressing arrow keys with ctrl. I searched everywhere, but found nothing. Can anyone help, please? My browser is Chrome v.96.+ React version 17.0.2, node v.16.13.1

 const HomePage = () => {
  const keyPressHandler = (e) => {
    if (e.repeat) return;
    if (e.key === "ArrowDown") {
      window.scrollBy(0, window.innerHeight);
    }
    if (e.key === "ArrowUp") {
      window.scrollBy(0, -window.innerHeight);
    }
  };

  return (
    <Container tabIndex="0" onKeyDown={keyPressHandler}>
      <div
        style={{ width: "100%", height: "100vh", backgroundColor: "green" }}
      />
      <div
        style={{ width: "100%", height: "100vh", backgroundColor: "gray" }}
      />
      <div style={{ width: "100%", height: "100vh", backgroundColor: "red" }} />
    </Container>
  );
};
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I fixed this creating new project and pasting this code there. I had some issues while installing react-icons dependencies and I stopped it manually. I think I get an error there

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda