Accelerator Key ... Question(s)

J

JimP

To All,
2 questions ...

I currently display a USERFORM in 2 ways ...
A)I can Click on the (activeX) Command button labeled "Menu" on the
sheet or
B) From anywhere on the sheet, I can use the accelerator key
combination of <Alt><m>

1) How do I determine immediately following the USERFORM displaying -
if the <Alt> key is still being depressed?
'''''''''''''''''''''''''''''''''''
2) HOW DO I TEST FOR THE ALT KEY using the Windows API?
I'm aware of trapping for the Control Key or the Shift Key with code
similar to the following:

' To do subsequent checks for SHIFT (or) CNTL Key
Declare Function GetKeyState32 Lib "user32" Alias _
"GetKeyState" (ByVal vKey As Integer) As Integer

ShiftDown = (GetKeyState32(16) < 0)
CtrlDown = (GetKeyState32(17) < 0)
'''''''''''''''''''''''''''''''''''

Any Help would be greatly appreciated ...

JimP
 
D

Dave Peterson

This seemed to work ok for me:

Option Explicit
Private Sub CommandButton1_Click()

Dim ShiftDown As Boolean
Dim CtrlDown As Boolean
Dim AltDown As Boolean

ShiftDown = (GetKeyState32(16) < 0)
CtrlDown = (GetKeyState32(17) < 0)
AltDown = (GetKeyState32(18) < 0)

MsgBox ShiftDown & vbLf & CtrlDown & vbLf & AltDown

End Sub
 
J

JimP

Thanks Dave ... Appreciate the help ...
JimP

Dave Peterson said:
This seemed to work ok for me:

Option Explicit
Private Sub CommandButton1_Click()

Dim ShiftDown As Boolean
Dim CtrlDown As Boolean
Dim AltDown As Boolean

ShiftDown = (GetKeyState32(16) < 0)
CtrlDown = (GetKeyState32(17) < 0)
AltDown = (GetKeyState32(18) < 0)

MsgBox ShiftDown & vbLf & CtrlDown & vbLf & AltDown

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top