Is there a way to control a slider with the keyboard arrow keys and not just clicking on the buttons on screen?

Inserting this into the Code Section on the page with the Slider works for me so far…
Jim

<script>
var Webflow = Webflow || [];
Webflow.push(function () {

$(document).keydown(function(e) {
    switch(e.which) {
        case 37: // left
          $('.w-slider-arrow-left').trigger('tap');
          break;
        case 38: // up
          break;
        case 39: // right
          $('.w-slider-arrow-right').trigger('tap');
          break;
        case 40: // down
          break;
        default: return; // exit this handler for other keys
    }
    e.preventDefault(); // prevent the default action (scroll / move caret)
});
});

</script>
7 Likes