It is not that easy.
KeyDown traps all keys, but if you want to trap all keystrokes on a form
regardless on which control has the focus, you need to set the KeyPreview
property of the form (or the UserControl) to True.
But be aware that some controls 'eats' some keystrokes for their internal
use; it is a bad policy, but there is nothing to do.
If you want to grab all keystrokes regardless on the active form, you have
to install a message hook in your application (you can find a lot of
examples,
looks for the SetWindowsHookEx API)
If you want to grab all keystrokes even if your application is not on the
foreground,
you needs to register a hot key (looks for the RegisterHotKey API)
m.
> -----Original Message-----
> From: LaFerriere, Patrick M. [SMTP:PLaFerriere@t...]
> Sent: Monday, March 19, 2001 10:50 AM
> To: professional vb
> Subject: [pro_vb] RE: key up / press / down
>
> The keydown will trap all keys. Your function keys and some of the other
> keys are not trapped by the keypress event. BTW this is a question on the
> certification exam
>
> -----Original Message-----
> From: Jonathan Allen [ <mailto:jonathan.allen@c...>]
> Sent: Monday, March 19, 2001 12:42 PM
> To: professional vb
> Subject: [pro_vb] key up / press / down
>
>
> How can i trap keyboard inputs on a form ?
> I am especially interested in stopping a user pressing the 'start' button
> and ctrl , alt , shift , del. Some of these are noticed but others seem to
>
> by-pass the keydown/keyup events.