469,903 Members | 1,595 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

KEYUP ,KEYDOWN EVENT

ZS
Hi,
On a form , I'm trying to trap when a shift key is pressed.
Can someone explain how the KeyUp,KeyDown and Key Press event works for Forms.
Thanks
-ZS
Nov 17 '05 #1
2 3803
To quote an article on MSDN
(http://msdn.microsoft.com/library/de...owntopic.asp):

Key events occur in the following order:
KeyDown
KeyPress
KeyUp

To handle keyboard events only at the form level and not allow other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true. Certain keys,
such as the TAB, RETURN, ESCAPE, and arrow keys are handled by controls
automatically. In order to have these keys raise the KeyDown event, you must
override the IsInputKey method in each control on your form. The code for the
override of IsInputKey would need to determine if one of the special keys is
pressed and return a value of true.

Brendan

"ZS" wrote:
Hi,
On a form , I'm trying to trap when a shift key is pressed.
Can someone explain how the KeyUp,KeyDown and Key Press event works for Forms.
Thanks
-ZS

Nov 17 '05 #2
ZS
Hi Brendan,
Thanks for responding. Okay I was able to trap the Key event .
But I want it to be fired only when the mouse is over a particualr control a
pictureBox actually. I'm going to try the Handled Event to see how it can be
trapped.
-Zelma

"Brendan Grant" wrote:
To quote an article on MSDN
(http://msdn.microsoft.com/library/de...owntopic.asp):

Key events occur in the following order:
KeyDown
KeyPress
KeyUp

To handle keyboard events only at the form level and not allow other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true. Certain keys,
such as the TAB, RETURN, ESCAPE, and arrow keys are handled by controls
automatically. In order to have these keys raise the KeyDown event, you must
override the IsInputKey method in each control on your form. The code for the
override of IsInputKey would need to determine if one of the special keys is
pressed and return a value of true.

Brendan

"ZS" wrote:
Hi,
On a form , I'm trying to trap when a shift key is pressed.
Can someone explain how the KeyUp,KeyDown and Key Press event works for Forms.
Thanks
-ZS

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by ShaneO | last post: by
6 posts views Thread by mingchin.AT | last post: by
3 posts views Thread by Luc The Perverse | last post: by
7 posts views Thread by win | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.