Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8227091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:00:25+00:00 2026-06-07T16:00:25+00:00

I need Keyboard events for viewing the next and previous for a larger images.

  • 0

I need Keyboard events for viewing the next and previous for a larger images. Please help me out. As I am viewing the images if am clicking on the mouse, like this I have to view the images If am clicking on left and right arrow keys too.

HTML

<div id="gallery">
    <div id="overlay"></div>    
    <div class="slidePanel">
      <div id="panel">
            <img id="largeImage" src="" />  
        </div>       
    <div class="slideBtn">
         <a href="#" id="next">
<img src="images/left_arrow.png" /></a> 
             <a href="#" id="prev"><img src="images/right_arrow.png" /></a> 
    </div>
    <div id="close"><a href="#">Close</a></div> 
    </div> 
        <div id="thumbs" align="center">
            <img src="images/image_01_thumb.jpg" alt="1st image description" />
            <img src="images/image_02_thumb.jpg" alt="2nd image description" />
            <img src="images/image_03_thumb.jpg" alt="3rd image description" />
            <img src="images/image_04_thumb.jpg" alt="4th image description" />
        </div>
    </div>

JS

function loadSlide(nSlide)
    {
        $('#thumbs img.current').removeClass('current');
        $(nSlide).addClass('current');

        var src = $(nSlide).attr('src').replace('thumb', 'large');
        $("#largeImage").fadeOut(function() 
        {
            this.src = src;
            $(this).fadeIn();

        }).center();
    $("#overlay").css({"opacity" : "0.7"})
                            .fadeIn("slow");    
    $('#close a, #close').fadeIn();
    $('#prev, #next').css('display', 'block');




    }

    $('#next').click(function()
    {   
        var cSlide = $('#thumbs img.current');
        if($(cSlide).next('img').length > 0)
            var nSlide = $(cSlide).next('img');
        else
            var nSlide = $('#thumbs img:first');

        loadSlide(nSlide);
    });

    $('#prev').click(function()
    {
        var cSlide = $('#thumbs img.current');  
        if($(cSlide).prev('img').length > 0)
            var nSlide = $(cSlide).prev('img');
        else
            var nSlide = $('#thumbs img:last');

        loadSlide(nSlide);
    });

    $('#thumbs img').click(function(){
        loadSlide(this);
    });



        $("#panel").click(function(){
            $(this).fadeOut("slow");
            $("#overlay").fadeOut("slow");
        });


    $('#close a').click(function(){

        $(this).fadeOut('slow');
        $('#overlay, #panel, #prev, #next, #largeImage').fadeOut('slow');
    $("#thumbs").css('display', 'block');

    });

    $('#thumbs img').click(function(){
    $("#thumbs").css('display', 'none');


    });



});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:00:26+00:00Added an answer on June 7, 2026 at 4:00 pm

    This should suit your needs, just slot it in, or if you need to use the left and right arrow keys elsewhere use $('#gallery') instead of $(document)

    $(document).keydown(function (e) {
      if (event.keyCode == 37) {
        $('#next').click(); //on left arrow, click next (since your next is on the left)
      } else if (event.keyCode == 39) {
        $('#prev').click(); //on right arrow, click prev
      }
    });
    

    EDIT: if you need any other keyCodes use this site: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to combine mouse and keyboard events in Win32, like Click + Shift
I need to be able to record keyboard events on elements that act like
I need to simulate some mouse events and keyboard events for my project and
Need to apply a filter to a file like this: TUPAC_0006:1:1:2554:2356#0/1 0 * 0
I need to be able to detect touch events on the keyboard. I have
How can I handle keyboard events in python? More exactly I need to manage
I know I need an event filter for Qt 4 to handle keyboard events.
Can a C# client record all keyboard and mouse events using hooks and collect
I'm using this library http://www.codeproject.com/Articles/28064/Global-Mouse-and-Keyboard-Library to record a macro. I want to know how
I have a C program that detects keyboard events, but I need to know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.