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

179
Vistas
Triger Next Prev function button when clicking the left right key

good day everyone... badly needed help how can I trigger the next prev function if I press the left and right arrow keys. this is for the slider/lightbox that I was assign into.

this is the code

$(document).ready(function() {
  var currentIndex = 0,
    navItems = $(".navindex");

  function setSlide(index) {...}

  $(".navindex").click(function() {
    var index = $(".navindex").index($(this));
    currentIndex = index;
    setSlide(currentIndex);
  });


  function next() {
    if (currentIndex < navItems.length - 1) {
      currentIndex++;
      setSlide(currentIndex);
    }
  }

  $(".next").click(function() {
    next();
  });

  function prev() {
    if (currentIndex > 0) {
      currentIndex--;
      setSlide(currentIndex);
    }
  }

  $(".prev").click(function() {
    prev();
  });


  function slide() {
    if (currentIndex < navItems.length - 1) {
      currentIndex++;
      setSlide(currentIndex);
    } else {
      currentIndex = 0;
      setSlide(currentIndex);
    }
  }

});

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You want to handle key events. Something along the lines of:

$(document).keyup((evt) => {
  if (evt.key === 'ArrowLeft')
    return prev();
  if (evt.key === 'ArrowRight')
    return next();
});
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