Results 1 to 5 of 5
  1. #1
    kanders
    Guest

    Using KeyDown Event

    How do I code the beginning of a KeyDown event to say that when the control key is pressed then the following events will happen (I already have the code for the events to take place when you press the control key)?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using KeyDown Event

    <pre>Private Sub MyKey_KeyDown(KeyCode As Integer, _
    Shift As Integer)
    If KeyCode = vbKeyControl Then
    KeyCode = 0
    'call your code here
    End If
    End Sub</pre>


    You would need to stick this code into each applicable control's KeyDown routine. The form's KeyDown event only occurs when the form has the focus.
    Charlotte

  3. #3
    kanders
    Guest

    Re: Using KeyDown Event

    Thanks it's working well!
    Just for my own education, what does the KeyCode = 0 mean?

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using KeyDown Event

    KeyCode=0 tells Access to not do the default action for the key that was pressed when your code returns.
    Legare Coleman

  5. #5
    kanders
    Guest

    Re: Using KeyDown Event

    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
  •