when we press a key and keep pressing it the keypress and keydown event continuously fires. Is there a way to let these fire only after a complete cycle ,eg keydown and then key up.
I would like the user not to be able press the key continuously rather would like the user have to press then release the key board to type a character !
so that following case do not occur eg : pppppppppppppppppppppppp when user presses 'p' for 1 sec.
To prevent a key from firing multiple-times when held down : you must use the
SuppressKeyPress
property like so :See : KeyEventArgs..::.Handled Property ... and ... KeyEventArgs..::.SuppressKeyPress Property .... for relevant information
Declare a boolean
isKeyDown
, in theKeyDown
Event, set the boolean to true. In theKeyUp
event, set the boolean to false.This is sample code
You can do it application-wide by filtering the key down messages with IMessageFilter. Here's an example:
One thing I pursued is the repeat count in the WM_KEYDOWN message. Oddly this didn't work on my machine, it was 1 for repeating keys. Not sure why.