Trapping Key Presses.

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

Guest

I want to trap a key press for my application but the application does not
seem to trigger the KeyPress,KeyDown or KeyUp events. I have a menu and a
picture on the main dialog. Is this a focus issue? or do I need to add
further event handling?
 
I want to trap a key press for my application but the application does not
seem to trigger the KeyPress,KeyDown or KeyUp events. I have a menu and a
picture on the main dialog. Is this a focus issue? or do I need to add
further event handling?

A form's KeyPress, KeyDown and KeyUp events are fired only if the form
itself has the focus. If a child control within the form has the focus,
then this is this control's KeyPress, KeyDown and KeyUp events that are
going to be fired. You can force your form's events to be fired first even
if the focus is on one of its child control by setting its KeyPreview
property to true.
 
Back
Top