Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Multiple keydown events fire while holding down key too long (Please help)

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #41615
    Rugg
    Participant

    Hello Everyone,

    There seems to be a few glitches with some jquery I’m working with. I’ve attempted a fix…having no luck. Hopefully the experts here can provide some assistance. Thank you.

    **Problem**
    Multiple keydown events are fired if a user holds down the key for an extended period of time.

    **Attempted Fix**
    Changed keydown to keyup _Failed to solve issue and affected desired output_

    **Goal**
    Fire keydown event only once if the user holds down the key…preventing continuous scrolling

    **Sample**
    http://jsfiddle.net/9JHS6/1/embedded/result/

    #119139
    tylerhq
    Member

    Something like this should work:
    http://jsfiddle.net/tylerhq/9JHS6/8/

    You’re allowed to use the up/down arrows once by setting a variable to true on keyup. Also, the e.preventDefault() prevents the browser window from scrolling up/down.

    #119423
    DustinWoods
    Member

    [Check this out](http://jsfiddle.net/VvU8d/embedded/result/). I combined both scripts. I think that should work for you.

    #119432
    DustinWoods
    Member

    I couldn’t simulate the issue you were having. But I have a hunch what was causing it. I updated the code, [try this](http://jsfiddle.net/6TCdY/embedded/result/). Does that fix it?

    #119519
    DustinWoods
    Member

    I actually just put the two scripts together, and had no issues. Haha.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.