
Capturing Keypress from Toolbar
The following routine can detect the state of the Shift, Ctrl & Alt keys.
Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Integer
Const VK_SHIFT As Integer = &H10 'Shift
Const VK_CONTROL As Integer = &H11 'Ctrl
Const VK_MENU As Integer = &H12 'Alt
Sub KeyView()
Dim msg As String
If GetKeyState(VK_SHIFT) < 0 Then msg = msg & "Shift "
If GetKeyState(VK_CONTROL) < 0 Then msg = msg & "Ctrl "
If GetKeyState(VK_MENU) < 0 Then msg = msg & "Alt"
MsgBox msg
End Sub
Quote:
> Hi
> I have a custom toolbar and would like to capture whether
> a person has the Shift key pressed when selecting one of
> the buttons.
> The button then calls a module.
> Is there any way you can capture key presses within a
> module which has been called from a form?
> Any help would be appreciated
> R