Results 1 to 6 of 6

Thread: Capturing KeyPresses...

  1. #1
    Guest
    Set the form's KeyPreview property to True.

    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = (192) Then Debug.Print ("~")
    End Sub

  2. #2
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    what does keypreview do

  3. #3
    Guest
    KeyPreview Property - Returns or sets a value that determines whether keyboard events for forms are invoked before keyboard events for controls. The keyboard events are KeyDown, KeyUp, and KeyPress.


  4. #4
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    is there a way to do this with the mouse?

    like: mousepreview?

  5. #5
    Guest
    Try this:

    Code:
    Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
    
    Private Sub Timer1_Timer()
    If GetAsyncKeyState(1) Then Debug.Print "Left mouse button"
    If GetAsyncKeyState(2) Then Debug.Print "Right mouse button"
    End Sub

  6. #6
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    cool, thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width