mrmccormack
mrmccormack

Reputation: 143

Bootstrap 3 keyboard not reacting to default keyboard events

Based on docs, /javascript/#carousel

keyboard boolean true

When I try there demo (which is using default setting)

http://getbootstrap.com/examples/carousel/

Note: (Mac 10.9.5, Safari 7.1.3, Firefox 36.0.1)

Safari, Never seems to respond to keyboard events.

FireFox Works sometimes, but when it does work if I click on the bottom of screen, it will ignore future keyboard events.

I've tried using:

$(document).ready(function(){

 $("#myCarousel").carousel({

     interval : false,

     pause: true,

     keyboard: true

 });

});

and that doesn't seem to help either.

Any suggestions? - Thanks, R

UPDATE

My Github issue has been closed with an explanation... https://github.com/twbs/bootstrap/issues/16164

Upvotes: 0

Views: 331

Answers (1)

oliverpool
oliverpool

Reputation: 1671

The code given in this answer works perfectly with your demo Just add this code at the very end of the document :

<script>
$(document).bind('keyup', function(e) {
    if(e.which == 39){
        $('.carousel').carousel('next');
    }
    else if(e.which == 37){
        $('.carousel').carousel('prev');
    }
});
</script>

Upvotes: 1

Related Questions