The situation . I have a handler keydownwith switchfor which key is pressed, fairly standard material, but when a key is held, the event keydownfires repeatedly (more than once, when the key is pressed).
Why is this a problem . I want the active listener to keydownbe active, i.e. could detect several keystrokes of one key at once, but it has only fire events once per keydown. I want to do something on keyupthis keyCodebased on the time between decrease and increase, but this time is twisted due to the many triggers.
What I tried : I am currently saving a list keyCodesthat do not work, and checking them in a handler keydownso that the default behavior does not occur if it is keyCodeon my list. Nevertheless, the event is still very often triggered, and I am concerned about the effectiveness / elegance of this solution.
Actual question : is there a good way to limit the triggering of an event keydownonly when the key is physically pressed down or only for listening to certain key codes?
source
share