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

178
Views
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 answers
Answer question

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