Grow your CSS skills. Land your dream job.

Scrolling on keypress, need to limit the number of times it fires

  • # May 15, 2013 at 6:21 am

    Hey, I am making a single page website which is similar to [this](http://m2mobi.com) site. I have achieved the scroll on keypress using jQuery and scrollTop() function.
    Although if you scroll the website mentioned in the link with your arrow keys you will see that after on keypress another keypress is not registered till the scroll is completed.
    In my site it scrolls every time the arrow key is pressed. How can I achieve the scrolling as above

    # May 15, 2013 at 7:34 am

    What I think you are asking is “how do I stop keyboard interaction during the scroll”…No?

    # May 15, 2013 at 7:37 am

    @Paulie_D Exactly…yes

    # May 15, 2013 at 9:45 am

    With a lock on interaction during scrolling, set a var to false when scrolling starts and true when scrolling ends and only scroll on keypress if the var is true. If you need more help make a CodePen with what you have so far.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".