Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

VB6 Detect Ctrl Key


ghost's Avatar
0 0

I have an app in vb 6, that I want it to run a function only when the user presses the Ctrl key. Like if I am in a full screen game, and I have my app running, it would detect the Ctrl key, and run the function I specify till the ctrl key is released. I am lost in doing this if anyone could help with this. I have looked at how keyloggers use the GetSync or what ever it was, but I was lost on how to make it recognize the Ctrl key only. Thanks for any help :D


ghost's Avatar
0 0

Private Sub Form_Load()
Timer1.Interval = 10
End Sub

Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyControl) Then MsgBox "Ctrl!!!"
End Sub```

Hope this will help but I don't understand what do you mean by saying "run the function I specify till the ctrl key is released". Is there a loop in your function and you want to stop it when Ctrl is released?

ghost's Avatar
0 0

well yeah, like if you have ever used Ventrillo, and used a key binding to talk, (i use ctrl), then you push down ctrl, start talking and when you release your press down on ctrl, it deactivates your voice from being heard by the other people in your ventrillo channel.