Last active
June 22, 2017 20:42
-
-
Save dylanvalade/7091619 to your computer and use it in GitHub Desktop.
Bootstrap carousel keyboard event controls for next and previous slides.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Register keyboard events | |
$(document).keydown(function(e) { | |
if (e.keyCode === 37) { | |
// Previous | |
$(".carousel-control.left").click(); | |
return false; | |
} | |
if (e.keyCode === 39) { | |
// Next | |
$(".carousel-control.right").click(); | |
return false; | |
} | |
}); |
This solution isn't good because: 1 - it relies on jQuery; 2 - doesn't unsubscribe the keydown listener. I'll probably submit a pull request adding the functionality
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can this be modified to work for any image gallery?