Fullpage.js - vertical scrolling with keyboard

I hope someone can help me with my problem below.

I am using the Fullpage.js plugin ( https://github.com/alvarotrigo/fullPage.js/ ) to create a site where pages move horizontally. The plugin is designed for building full page sites where it vertically scrolls through each section by scrolling or pressing keys, just like a parallax site.

In my file, I only use one left and right arrow section to contain multiple pages for horizontal scrolling. As an example at http://alvarotrigo.com/fullPage/examples/scrolling.html Since I don't have multiple sections, when I press the up / down keys it doesn't scroll the content at all.

Any suggestions would be greatly appreciated. Thanks in advance!

+2


source to share


1 answer


Just assign the fullpage functions moveSlideRight

and moveSlideLeft

to the keyboard shutdown events and disable the default fullpage.js keyboard scrolling by using$.fn.fullpage.setKeyboardScrolling(false)

$(document).keydown(function (e) {
    var shiftPressed = e.shiftKey;

    switch (e.which) {
        //up
        case 38:
        case 33:
            $.fn.fullpage.moveSlideLeft();
            break;

        //down
        case 40:
        case 34:
            $.fn.fullpage.moveSlideRight();
            break;

    }
});

      



Demo online

+1


source







All Articles