slick: Arrow key navigation not working
Autoplay working well, but draggable and accessibility aren’t working. The slides can’t be dragged or moved with the right/left arrow keys.
$(document).ready(function(){
$('.slider').slick({
dots: true,
focusOnSelect: true,
autoplay: true,
draggable: true,
autoplaySpeed: 6000,
infinite: true,
pauseOnHover: false,
swipeToSlide: true,
arrows: false,
accessibility: true,
});
});
Thank you.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 22 (4 by maintainers)
@gitsaagar Yes, .focus() will not work on divs and lists. Looks like the only solution is use key events
This got it to work in the end
$(document).find('.slick-list').attr('tabindex', 0).focus();
@v3nt how about
Ran into the same problem. I’m dynamically setting up the slider like a lightbox after a user clicks on an image. My solution was to set a timeout before focusing:
Using only the
init
event did not help. Another solution, might be helping someoneis there a way we can set the slider as focused when the page loads? ie so the keypresses work straight away?
Ah, I get the picture now. The arrow keys are working only if the slider is focused. I revisited the fiddle above, and yes during initial load the arrow keys are not working. That’s because the focused element is not the slider.
If you interact with the slider, either you click or drag it, then the arrow keys work.