KEYUP ,KEYDOWN EVENT

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
To quote an article on MSDN
(http://msdn.microsoft.com/library/d...ystemwindowsformscontrolclasskeydowntopic.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
 
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
 
Back
Top