44067

Keyboard arrow keys navigation with Easy Slider 1.7

Question:

I'm trying to edit the <a href="http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider" rel="nofollow">Easy Slider</a> to allow the keyboard's arrow keys to navigate the slideshow.

I tried editing the <a href="http://stanford.edu/group/webdev/champions/js/easy-slider.js" rel="nofollow">javascript's</a> animate function from:

default: t = dir; break;

...to:

default: t = parseInt(dir); break;

...but that didn't work.

Does anyone know how to use the keyboard's arrow keys to navigate this slideshow?

Answer1:

Assuming your next and prev links have IDs of #next and #prev:

$(document).keydown(function(e){ if (e.keyCode == 39) { $('a#next').trigger('click'); } else if (e.keyCode == 37) { $('a#prev').trigger('click'); } });

I'm also not familiar with easy slider, but if they have a way to programmatically switch the slides back and forth, then you could swap out the triggers with those. The posted solution will work fine though.

Recommend

  • CSS Bundling and Internet Explorer's Limit
  • Function to check if jquery plugins are already initialized
  • Why doesn't >= (greater than or equals) comparison work in Javascript?
  • getting java.lang.ClassCastException: class java.lang.String in running a simple MapReduce Program
  • d3.js create stacked bar chart from values in object
  • AJAX Chat Box Scrolling Up Issue
  • jQuery, Calling multiple animations in a row on click
  • Price range slider for my website
  • Change the width of the JQM panels
  • Variant from android-autofittextview library : scaling makes strange behaviour
  • Keep transition effect on 1 div from moving the div that follows?
  • How to populate html table with info from list in django
  • Prevent page break in text block with iText, XMLWorker
  • Changing Jupyter Notebook start up folder by modifying “start in” not working any more
  • Using MouseListener to select a range of cells in a grid
  • Shouldn't else be indented in the below code
  • How to explicitly/implicitly implemented interface members in C++/CLI?
  • List images(01.png) and descriptions(01.txt) from directory
  • Copy to all folders batch file?
  • OOP Javascript - Is “get property” method necessary?
  • WPF - CanExecute dosn't fire when raising Commands from a UserControl
  • How to test if a URL from an Eclipse bundle is a directory?
  • Cancel a live stream “fast motion” catch-up in Flash
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Spray.io: When (not) to use non-blocking route handling?
  • HTML download movie download link
  • Updating server-side rendering client-side
  • Modifying destination and filename of gulp-svg-sprite
  • Do create extension work in single-user mode in postgres?
  • GridView Sorting works once only
  • R: gsub and capture
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • File upload with ng-file-upload throwing error
  • How to set the response of a form post action to a iframe source?
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?