Key repetition

R

Romain TAILLANDIER

Hi group

I have a control looking like a TrackBar, a bar, with a cursor.
I need when the user push the left arrow of his keyboard, the cursor
move left until the key released.
I have overloaded the OnKeyDown method like this :

protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);

switch(e.KeyCode)
{
case Keys.A :
this.SelectedBlock--;
break;
default:
break;
}
}

It work very good with the A Key, but the event for left arrow doesn't
fire !
only the OnKeyUp is fired by the Left Arrow key.

I can't implement the repetition keystroke for arrows, or control,
shift ....

However, the ListView control for exemple allow me to scroll all the
list by push the down arrow, without release it.

How to make the repetition of the left arrow key ?
Thanks

ROM
 
G

Gabriele G. Ponti

Read the Remarks section of the Control.KeyDown event.

If you're using 2.0 you can try the Control.PreviewKeyDown event, from a
quick test it seems to be working with the arrow keys.
 

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