KeyPress concept?

G

Guest

In old Visual Basic there was a KeyPress event that happened when a key was
released some max time after it was pushed. I guess this was to allow a press
to be cancelled if held down for a while (like holding down a button) Is
there any such system-defined time between keydown and keyup that makes a
KeyPress, that I can use through .NET?
 
S

Stoitcho Goutsev \(100\)

wikoh,

I don't know what exactly KeyPress does in VB6, but windows forms controls
fire three key events. One of them I think may help you with what you need.

Look at the windows forms Control class in MSDN. There are KeyDown, KeyUp,
KeyPress - they all have Handled property that can be used to cancel the
default processing of the event.
 
G

Guest

wikoh said:
In old Visual Basic there was a KeyPress event that happened when a key was
released some max time after it was pushed. I guess this was to allow a press
to be cancelled if held down for a while (like holding down a button) Is
there any such system-defined time between keydown and keyup that makes a
KeyPress, that I can use through .NET?

Unfortunately there is no key event whcih occurs after a certain time. All
..NET key events fire in response to the user pressing or releasing a key.

There are three key events which occur in the following order:

1. KeyDown
2. KeyPress
3. KeyUp

The KeyPress event is raised only by character keys (e.g., not by the Shift
or F1 keys, etc.) The KeyPress event fires immediately after the KeyDown
event. Of course, the KeyUp event fires once the user releases the key.

Hence, to fire an event after a certain amount of time after a key has been
pressed, you will need to create a timer, and start the timer after the
KeyDown event has been pressed.
 

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