What do you think about adding keyboard navigation as a built-in feature, or a plugin?
Good idea! Should be added as a plugin.
This should really be built-in. Many people need keyboards to use the web--by building it into the carousel, accessibility will be improved by default.
+1 to @marcysutton. The web is for everyone, not just for mouse-using people with perfect eyesight.
I agree that this should be added as a default plugin. Currently the drag feature is part of the core, but this temporary. So both input methods (drag and keyboard) should at least optional available as plugins.
Love the plugin, but can't use it without keyboard functionality. Was going to use it on TV app but TV needs the next, prev and enter keys.
Hope it will be released soon.
This little hack will enable next and prev keys:
$(document).keydown( function(eventObject) {
if(eventObject.which==37) {//left arrow
$('.owl-prev').click();//emulates click on prev button
} else if(eventObject.which==39) {//right arrow
$('.owl-next').click();//emulates click on next button
}
} );
The default elements for navigation are not focusable either (prev/next and dots). If they were, basic keyboard navigation (tab and enter/space) would be available now.
I was considering doing some work on that part and submitting a pull request but don't want to duplicate the effort if this'll be considered anyway?
Modifying something like
$('#articles-top-navigation').children('.owl-dot').attr('tabindex', 0).attr('role', "button");
$('.owl-carousel .owl-controls .owl-nav div').attr('tabindex', 0).attr('role', "button");
$('.owl-carousel .owl-controls .owl-nav owl-next').attr('aria-label', "Nästa artikel");
$('.owl-carousel .owl-controls .owl-nav owl-prev').attr('aria-label', "Föregående artikel");
will make the dots and next/previous elements to be focusable and "buttons" but they still don't listen to keypresses.
Would be great to customize what kind of element you want for these items.
According to http://www.nczonline.net/blog/2013/01/29/you-cant-create-a-button/ you just want them to be buttons.
I would also really appreciate if the slider would respect wcag2. Keyboard Usage is just the beginning ;)
FYI: W3C has a tutorial which describes how to do an accessible carousel: http://www.w3.org/WAI/tutorials/carousels/
Disclaimer: I鈥檓 the editor of that document.
What's the status of this functionality? I'm hoping to using Owl Carousel 2 with arrow keys.
@alexelash Here, you can use this for now:
var $owl = $( '#owlCarousel' );
$owl.owlCarousel(); //initialize
$(document).on('keydown', function( event ) { //attach event listener
if(event.keyCode == 37) {
$owl.trigger('prev.owl')
}
if(event.keyCode == 39) {
$owl.trigger('next.owl')
}
});
Thank you @pajasevi
In case anyone's interested, I'm working on an accessibility layer for Owl Carousel v2 which includes keyboard navigation as a feature: https://github.com/rtrvrtg/owlcarousel2-a11ylayer
I'm also working on a similar layer for v1, which v2 will hopefully have the same feature set as once I get round to it.
:+1:
馃憤
i made a pull request for this feature: #991
read too late the note about tag "approved for development" :tired_face:
Very simple, thank you @pajasevi! 馃憤
Hello, you are going too far by using javascript, just replace the current.
by a button tag and style them using CSS. The button need to have the attr type="button" too.
Any luck in a solution?
Any updates on this?
Most helpful comment
@alexelash Here, you can use this for now: