I want to have this code in the keydown event that if ctrl and g are pressed a certain thing happens... How do I do this
Printable View
I want to have this code in the keydown event that if ctrl and g are pressed a certain thing happens... How do I do this
Chage Form's KeyPreview property to TRUE and put this code on Form's KeyDown event:
------------------Code:Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (Shift And vbCtrlMask) > 0 Then
If KeyCode = vbKeyG Then
'Do your things here............
End If
End If
End Sub
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
Or you simply use the keyup event instead
test this and the msgbox willshow what key's are pressed. here are the constants.
Constant Value Description
vbShiftMask 1 SHIFT key bit mask.
VbCtrlMask 2 CTRL key bit mask.
VbAltMask 4 ALT key bit mask.
here is some code:
------------------Code:Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If Shift Then
MsgBox Shift & " " & KeyCode
End If
End Sub
On Error Goto Bed :0)
[email protected]
[This message has been edited by onerrorgoto (edited 11-18-1999).]
Key_up event is being triggered twice any idea what could be causing this ?
[This message has been edited by Inhumanoid (edited 11-18-1999).]
??
Two msgboxes??
------------------
On Error Goto Bed :0)
[email protected]
In this case it doesn't make any difference. You can use my code on Key_Up event.
Inhumanoid, for your question (why it happens twice). Do you have my code on Key_Down event and the code on Key_Up event???
nope.... I make the keydown ctrl+w event call a buttons click event... I switched to the debugger, when it's done with the click event it finishes the keydown event and then does i t again.....
I think I'll have to solve this one my self cause it's probably some bug caused by something that has nothing to do with the keyup event....
But thanx for the code...