repeating key while holding a key down

  • Thread starter Thread starter news.austin.rr.com
  • Start date Start date
N

news.austin.rr.com

Hi,

I want to be able to hold a key down and cause an on screen graph cursor to
accelerate (position += 10;) across the screen.

The problem is when I press and hold a key (an actual keyboard key on a
custom device) none of the events KeyPress, KeyDown, or KeyUp fire until I
release the key. I was hoping a KeyPress or KeyDown event would fire when I
press and hold a key. Then I would start a timer where I would accelerate
the cursor position on each timer event execution. Then turn the timer off
when the key is released. But. the key events don't fire until after I
release the key :(

Anyone know a work around?

The keys fire in one of the 2 orders depending on the type of key pressed.

KeyDown > KeyPress > KeyUp (i.e. numeric keys "1")

or

KeyUp > KeyDown > KeyUp (i.e. Function Keys)


Anyone know a work around?
 
This is rather strange as in my experience key autorepeat works, but hey,
you have a custom device...
In this scenario I would suggest starting a timer when you get keydown and
stopping it on KeyUp. On timer event do what you were planning to do on
repeated KeyDown. You may also find it useful to PInvoke GetAsyncKeyState to
check if a particular key is down.
 
Back
Top