VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Dedect keypress

by -raistlinthewiz- Huseyin Uslu (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

This code finds if any key pressed. This will be helpfull for example you're programming a screensaver. But you can not get keypresses through forms because of some components which does not support this keypress event. So you must use some API's to do this.

API Declarations
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Rate Dedect keypress

sKeyStat = 0
For i = 0 To 255
 KeyResult = GetAsyncKeyState(i)
  If KeyResult = -32767 Then
   sKeyStat = 1
   Exit For
  End If
Next i
 If sKeyStat = 1 Then
  msgbox "Key pressed!!!"
 End If

Download this snippet    Add to My Saved Code

Dedect keypress Comments

No comments have been posted about Dedect keypress. Why not be the first to post a comment about Dedect keypress.

Post your comment

Subject:
Message:
0/1000 characters