Get both the Keycode and Ascii values of keys pressed
Use this app to get the Ascii values of the keys on the keyboard.
Last edited by Nightwalker83; Apr 29th, 2011 at 03:39 AM.
Reason: Reuploading source code!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
Get both the Keycode and Ascii values of keys pressed
Hi,
This code will output (to a text file) the ascii value of the key on the keyboard which was pressed. This code was written in Visual Basic 6.0.
vb Code:
Private Sub Command1_Click()
Unload Me
'End
End Sub
Private Sub Text1_Change()
Open App.Path & "\keyboard.txt" For Append As #1
Print #1, Label2.Caption & " " & Text1.Text
Close #1
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Label2.Caption = Chr(KeyCode)
Text1.Text = KeyCode
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Label2.Caption = Chr(KeyAscii)
MsgBox "Asciikey: " & KeyAscii
End Sub
Edit:
The commented out parts were apart of the original code but are not needed to preform the task suggested in the thread title.
Nightwalker
Last edited by Nightwalker83; Mar 15th, 2010 at 08:28 PM.
Reason: Fixing spelling
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
Re: Get both the Keycode and Ascii values of keys pressed
Originally Posted by akhileshbc
I found that you are using End in most of your projects. That's not a good practice.
Good luck ...
Yeah, I know! However since, it has been years since I originally wrote the code I hadn't double checked to make sure I used unload me instead of end.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
Re: Get both the Keycode and Ascii values of keys pressed
Originally Posted by Nightwalker83
Yeah, I know! However since, it has been years since I originally wrote the code I hadn't double checked to make sure I used unload me instead of end.
Why don't you edit your post(the above one) and include it now...???
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
Re: Get both the Keycode and Ascii values of keys pressed
Originally Posted by akhileshbc
Why don't you edit your post(the above one) and include it now...???
I have amended post #3 and put unload me in Command1_Click but I has left the end in there but commented it out. There is an explanation of why I did this in post #3.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
Re: Get both the Keycode and Ascii values of keys pressed
Originally Posted by Nightwalker83
I have amended post #3 and put unload me in Command1_Click but I has left the end in there but commented it out. There is an explanation of why I did this in post #3.
....
Originally Posted by Nightwalker83
Edit:
The commented out parts were apart of the original code but are not needed to preform the task suggested in the thread title.
Nightwalker
Then I think, this code block itself is not needed:
Code:
Private Sub Command1_Click()
Unload Me
'End
End Sub
( I am just expressing my thoughts )...
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
Re: Get both the Keycode and Ascii values of keys pressed
Originally Posted by akhileshbc
....
Then I think, this code block itself is not needed:
Code:
Private Sub Command1_Click()
Unload Me
'End
End Sub
( I am just expressing my thoughts )...
Ah well, the users can decided whether they want to keep it in there or not. Maybe it will come in handy for something else I'm not forcing them to use any of the code.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672