Skip to main content
July 11, 2008
Question

How do you disable repeat when key is down?

  • July 11, 2008
  • 2 replies
  • 1242 views
When you press a key on your keyboard and hold that key down (the "A" key for example), after a second or so, it would start to repeat (so you would get "AAAAAA..." depending on how long you hold it down). This is really inconvenient for me in Flash and was wondering if there is a way to disable this or stop this from happening.
I have this code in a file:
stage.addEventListener(KeyboardEvent.KEY_DOWN, moveBox);
I only want the moveBox function to be executed once, but if a key is held down for longer it executes multiple times.

Thanks in advance for any help.

-Robert K.
This topic has been closed for replies.

2 replies

Inspiring
July 12, 2008
An approach to try is to remove the event listener in the listener function for the keyDown event and then add the event listener again in the keyUp event listener.

TS
Participant
July 12, 2008
Hey twinbird,

I had to solve the same problem and this is how I did it.