Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOT KEY - COMBINATION FROM TWO BUTTONS

Status
Not open for further replies.

IrinaK

Programmer
May 21, 2001
33
US
Hello!
I need to combine two buttons: "shift" and "2".
How can I check it in code (vbkeyshift and vbkey2)?

Thanks.
 
Try this...

Create a form and place a text box in it called txtKey, use the following code to experiment with different keystrokes...
Code:
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  Dim skc: skc = Chr(KeyCode)
  
  Select Case Shift
    Case 0 'no modifier keys
      txtKey.Text = "You pressed " & skc
    Case 1 'Shift is down
      Select Case skc
        Case "S"
          txtKey.Text = "You pressed Shift-S"
      End Select
    Case 2  'CTRL is down
      txtKey.Text = "You pressed ALT-" & skc
    Case 3  'CTRL-SHIFT is down
      txtKey.Text = "You pressed CTRL-SHIFT-" & skc
    Case 4  'ALT is down
      txtKey.Text = "You pressed ALT-" & skc
    Case 5  'SHIFT-ALT is down
      txtKey.Text = "You pressed SHIFT-ALT-" & skc
    Case 6  'CTRL-ALT is down
      txtKey.Text = "You pressed CTRL-ALT-" & skc
    Case 7  'CTRL-ALT-SHIFT is down
      txtKey.Text = "You pressed CTRL-ALT-SHIFT-" & skc
    Case Else
      txtKey.Text = "huh? SHIFT=" & Shift & " KEYCODE=" & KeyCode
  End Select

End Sub

Hope it helps, Rob
robschultz@yahoo.com
-Focus on the solution to the problem, not the obstacles in the way.-
 
Thank you very much.

And I found another (similar answer in this forum):
If Shift And vbShiftMask Then
If KeyCode = vbKey2 Then
'it's shift + key2
end if
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top