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

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

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