Solved

Combo Keypress

Posted on 2006-06-14
5
191 Views
Last Modified: 2010-04-30
How would I make an application recognize something like ctrl+shift + letter d? I know how to do it for one key but not a combination.
0
Comment
Question by:arajoe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 8

Expert Comment

by:List244
ID: 16904109
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Form1.Caption = GetKeyState(vbKeyControl)
If GetKeyState(vbKeyShift) < 0 And GetKeyState(vbKeyControl) < 0 And GetKeyState(vbKeyD) < 0 Then
    MsgBox "Shift + Control + D"
End If
End Sub
0
 
LVL 8

Accepted Solution

by:
List244 earned 250 total points
ID: 16904120
Or better fit for a combo:

Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If GetKeyState(vbKeyShift) < 0 And GetKeyState(vbKeyControl) < 0 And GetKeyState(vbKeyD) < 0 Then
    MsgBox "Shift + Control + D"
End If
End Sub
0
 

Author Comment

by:arajoe
ID: 16904193
Sorry its not for a combo but a form in general. I meant a combination of buttons. What I want to do is hit cont shift d and bring the application into debug mode.
0
 

Author Comment

by:arajoe
ID: 16904202
got it with that code. just put it into the forms keypress.
0
 
LVL 8

Expert Comment

by:List244
ID: 16904205
Arajoe, that first example will catch Control + Shift + D, where I do my message box, you should put the code you want.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month3 days, 17 hours left to enroll

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question