malsup / cycle2

2nd gen cycling
899 stars 238 forks source link

Cycle2 keyboard navigation (again, revisit of #44) #716

Open aelTEG opened 9 years ago

aelTEG commented 9 years ago

GitHub malsup/cycle2 addressed keyboard navigation before long ago - see item 44 - to enable advancing or moving back within a slideshow using keyboard arrow keys. With addition of an omitted semicolon, MAlsup endorsed the following snippet:

//gallery keyboard events $(document.documentElement).keyup(function (event) { if (event.keyCode == 37){ $('.slider').cycle('prev'); }else if (event.keyCode == 39){ $('.slider').cycle('next'); } });

I am a novice at this, but I did try its inclusion as shown, alone and within < div > < /div >, and < script > enclosures the last even with type javascript, but apparently have not pasted it in the correct place to function. Does it go in the calling html and if so in the or sections and if so is there required sequence (e.g., after the calls to jQuery and Cycle2 plugins, a CSS file, a modified (appended) jquery.cycle2.js, or where? The answer probably is trivial, but still elusive for a beginner. Can anyone provide a top-to-bottom code example showing the snippet placement or, preferably, one or more URL(s) for a functioning, simple (not so complex as to hide the matter) slideshow example incorporating keyboard navigation?

Thank you.

aelTEG

aelTEG commented 9 years ago

Edited (corrected) question after revision in the submission:

Does it go in the calling html and if so in the < html > or < body >sections and if so is there a required sequence (e.g., after the calls to jQuery and Cycle2 plugins, a CSS file, a modified (appended) jquery.cycle2.js, or where?