Ninja Slider / Posts /

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

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

5 Answers


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); } 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   10 years ago

great post here. . . this really answered my problem, thank you!

  4 years ago

Yes, you can enable keyboard navigation by adding the following script to the  HTML page. 

word search

peterparkerrbu   one year ago

hi.its not work.plz edit it

yasaman   8 years ago

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   8 years ago


Your name*
(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: