Click to See Complete Forum and Search --> : How to catch a keyboard key?
Sigal Laniado
January 11th, 2000, 05:48 AM
I have an explorer style application (with 2 user controls - tree and list, toolbar etc..)
I need to know when the user presses the "Ctrl" key in any place in the application.
What is the way to do it?
Thanks Sigal
Lothar Haensler
January 11th, 2000, 06:11 AM
set the Keypreview property of the form to true and trap all keypress, keydown, keyup event at the Form_Keypress event handler level
Lothar Haensler
January 11th, 2000, 06:13 AM
sample:
private Sub Form_KeyDown(KeyCode as Integer, Shift as Integer)
If Shift And vbKeyControl = vbKeyControl then
MsgBox "control pressed"
End If
End Sub
Sigal Laniado
January 11th, 2000, 06:27 AM
Thanks but i have more then two forms and i don't want to define the Form_KeyDown routine in every form
I want that the main form will catch the key of its child forms.
Lothar Haensler
January 11th, 2000, 07:04 AM
check out http://www.vbaccelerator.com/codelib/ssubtmr/hotkeyr.htm
It deals with registering application wide hotkeys.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.