|
-
Oct 9th, 2009, 02:13 PM
#1
Thread Starter
Hyperactive Member
-
Oct 9th, 2009, 02:19 PM
#2
Re: CTRL+SHIFT+N in keydown function
In the keydown event, look for (Shift = (vbCtrlMask Or vbShiftMask)) and also that KeyCode is vbKeyN.
-
Oct 9th, 2009, 02:23 PM
#3
Re: CTRL+SHIFT+N in keydown function
If you mean how dop you detect it then...
Code:
Dim ShiftTest As Integer
ShiftTest = Shift And 7
Select Case ShiftTest
' Case 1 ' or vbShiftMask
' Print "You pressed the SHIFT key."
' Case 2 ' or vbCtrlMask
' Print "You pressed the CTRL key."
' Case 4 ' or vbAltMask
' Print "You pressed the ALT key."
Case 3
' Print "You pressed both SHIFT and CTRL."
If KeyCode = vbKeyN Then
Print "You pressed both SHIFT and CTRL and N."
End If
' Case 5
' Print "You pressed both SHIFT and ALT."
' Case 6
' Print "You pressed both CTRL and ALT."
' Case 7
' Print "You pressed SHIFT, CTRL, and ALT."
End Select
-
Oct 9th, 2009, 02:24 PM
#4
Thread Starter
Hyperactive Member
-
Oct 9th, 2009, 02:29 PM
#5
Thread Starter
Hyperactive Member
-
Oct 9th, 2009, 02:31 PM
#6
Re: CTRL+SHIFT+N in keydown function
You're welcome. Now please mark the thread resolved.
-
Oct 9th, 2009, 02:32 PM
#7
Thread Starter
Hyperactive Member
-
Oct 9th, 2009, 02:44 PM
#8
Re: CTRL+SHIFT+N in keydown function
From Help.
The mouse and keyboard events use the shift argument to determine whether the SHIFT, CTRL, and ALT keys are pressed and in what, if any, combination. If the SHIFT key is pressed, shift is 1; if the CTRL key is pressed, shift is 2; and if the ALT key is pressed, shift is 4. To determine combinations of these keys, use the total of their values. For example, if SHIFT and ALT are pressed, shift equals 5 (1 + 4).
The three least-significant bits in shift correspond to the state of the SHIFT, CTRL, and ALT keys, as shown in Figure 11.5.
Figure 11.5 How bits represent the state of the SHIFT, CTRL, and ALT keys
Any or all of the bits in shift can be set, depending on the state of the SHIFT, CTRL, and ALT keys. These values and constants are listed in the following table:
Binary Value Decimal Value Constant Meaning
001 1 vbShiftMask The SHIFT key is pressed.
010 2 vbCtrlMask The CTRL key is pressed.
100 4 vbAltMask The ALT key is pressed.
011 3 vbShiftMask + vbCtrlMask The SHIFT and CTRL keys are pressed.
101 5 vbShiftMask + vbAltMask The SHIFT and ALT keys are pressed.
110 6 vbCtrlMask + vbAltMask The CTRL and ALT keys are pressed.
111 7 vbCtrlMask + vbAltMask + vbShiftMask The SHIFT, CTRL, and ALT keys are pressed.
As with the mouse events' button argument, you can use the If…Then…Else statement or the And operator combined with the Select Case statement to determine whether the SHIFT, CTRL, or ALT keys are being pressed and in what, if any, combination.
-
Oct 9th, 2009, 02:45 PM
#9
Re: CTRL+SHIFT+N in keydown function
Look up Detecting SHIFT, CTRL, and ALT States in Help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|