Search code examples
javascriptvelocity.js

Velocity JS disable scroll on arrow key press


Extensively reviewed documentation and didn't see an argument to disable scrolling when the arrow keys are pressed.

https://github.com/julianshapiro/velocity


Solution

  • I was able to resolve this issue by commenting out the code below found in "main.js". The '40' value indicated downarrow, '38' is up. This might help someone isolate and remove this functionality in other scripts.

            $(document).on('keydown', function(event){
                if( event.which=='40' && !nextArrow.hasClass('inactive') ) {
                    event.preventDefault();
                    nextSection();
                } else if( event.which=='38' && (!prevArrow.hasClass('inactive') || (prevArrow.hasClass('inactive') && $(window).scrollTop() != sectionsAvailable.eq(0).offset().top) ) ) {
                    event.preventDefault();
                    prevSection();
                }
            });