PDA

Click to See Complete Forum and Search --> : KeyDown wit multiple keys


Inhumanoid
Nov 17th, 1999, 08:52 PM
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

Serge
Nov 17th, 1999, 09:02 PM
Chage Form's KeyPreview property to TRUE and put this code on Form's KeyDown event:


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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

onerrorgoto
Nov 17th, 1999, 09:06 PM
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:

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)
anders@zsystemdesign.se



[This message has been edited by onerrorgoto (edited 11-18-1999).]

Inhumanoid
Nov 17th, 1999, 09:23 PM
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).]

onerrorgoto
Nov 17th, 1999, 09:28 PM
??
Two msgboxes??

------------------
On Error Goto Bed :0)
anders@zsystemdesign.se

Serge
Nov 17th, 1999, 09:33 PM
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???

Inhumanoid
Nov 17th, 1999, 10:06 PM
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...