开发者

How to integrate keyboard arrows with jCarousel - Using Keynav jQuery plugin?

开发者 https://www.devze.com 2023-01-30 03:50 出处:网络
Alright. The idea is that I have a jCarousel list that displays 3 items per view. I\'m using the jQuery Keynav plugin to navigate with the elements via keyboard arrow keys.

Alright. The idea is that I have a jCarousel list that displays 3 items per view. I'm using the jQuery Keynav plugin to navigate with the elements via keyboard arrow keys.

Now when I navigate (via keyboard arrows) to the items that are actually hidden in the carousel, the jCarousel must slides to the new view.

Is there any possibility this can be done? Or is there any other plugin -say Keynav plugin- that supports triggering events along with the key press?

Here's a live example http://www.jsfiddle.net/F4GCc/5/ (You'll ha开发者_Python百科ve to actually click in the "Result" pane for the keyboard arrow navigation to work.)


Just bind the document to keyup and check to make sure it's the left or right arrow:

$(document).on('keyup', function(e) {
    var key = e.which || e.keyChar || e.keyCode;
    if (key === 37)  {
      // left key
    } else if (key === 39) {
      // right key
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消