Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture Key Strokes

Status
Not open for further replies.

ryan1

Programmer
May 15, 2002
106
US
Does anybody know how to capture key strokes and set them equal to a string.
 
You can grab keystrokes using event procedures such as KeyDown, KeyUp, or KeyPress.

You may want to phrase your question a little more specifically to get a specific answer.
 
I'm trying to use the keystrokes as a filter. For example when the user starts to type i have a small form pop up and he can type what he wants to and click enter. This filters a listbox on a master form.(I pop the form up on a key press event but i always loose the first key the user pressed. )
 
It's kind of laborious, but you might want to try putting key down handlers in each form (and each control in each form). That seems to catch all the keyboard events. If you don't want to pass the keystroke on to the application, set the keycode and shift to 0:

Sub ProcessKeyDown(KeyCode As Integer, Shift As Integer)
Debug.Print "Down: " & Format(Now, "HH:NN:SS") & ", " & KeyCode & ", " & Shift
KeyCode = 0
Shift = 0
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top