repeating key while holding a key down

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?
 
A

Alex Feinman [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top