Ninja Slider / Posts /

How can I enable keyboard left and right keys to navigate the image slider?

8
Can I enable users  to use keyboard left and right arrow keys to navigate the responsive image slider?
Stephanie  3 years ago   viewed: 7767    

3 Answers

0

Yes you can add the following script into the HTML page to enable the keyboard navigation.

<script> function handleKeyboardNav(e) { if (!e) e = window.event; var kc = e.keyCode; if (kc == 37) nslider.prev(); if (kc == 39) nslider.next(); } function bindKeyDownListener() { if (document.addEventListener) document.addEventListener("keydown", handleKeyboardNav, false); else if (document.attachEvent) el.attachEvent("onkeydown", handleKeyboardNav); } //start the binding bindKeyDownListener(); </script>

The script can be added either at the end of your page(just before the </body> tag), or be added into the head section of the page. 

Milo   3 years ago
0

hi.its not work.plz edit it

yasaman   one year ago
0

Since the version v2015.10.21, the keyboard nav function is just built-in. You just need to set: {keyboardNav: true} in the ninja-slider.js (nsOptions).

Milo   one year ago

   

Your name*
Password
(Optional. Used to modify this post afterwords)
+ =  

Ask your Own Question

  • If your question is related to the topic of this post, you can post your question to this page by clicking the "Post a reply" button at left;

  • When you want to start a new page for your question: