reading unlimited simultaneous keypresses ?

  • Thread starter Thread starter Mad Scientist Jr
  • Start date Start date
M

Mad Scientist Jr

Can someone show how to read keypresses in VB.NET, for the entire
application (that is, independent on which control has the focus, just
read if a key on the keyboard is down or not) ?

I'm looking to do something like

for iLoop = 0 to 255 ' (loop through all keyboard/ASCII characters)
if keydown(iLoop) then
'blah
end if
next iLoop

I know some keyboards have limitations about how many simultaneous
keypresses their controller can send (press >8 keys at once, and
"ghost" codes get sent) but I'll be using a Hagstrom KE72 so this
should not be a problem. I want to be able to indpendently scan each
key, even if the user is somehow pressing all 101 keys.

Any help appreciated!
 
You can either use an IMessageFilter or override the WndProc to get the raw
windows messages sent to the application regardless of the control that has
focus. In these, you can try trapping the WM_KEYDOWN (WM_KEYDOWN = &H100 )
message and checking the keycode given. Then you can detect a key release
by trapping the WM_KEYUP (&H101) message.

However, based on your keyboard you may need to poll it instead of simply
accepting messages. I'm not sure how your key detection will need to work--
sorry to only give you half an answer
 
* (e-mail address removed) (Mad Scientist Jr) scripsit:
Can someone show how to read keypresses in VB.NET, for the entire
application (that is, independent on which control has the focus, just
read if a key on the keyboard is down or not) ?
[...]

I replied in another group. Please do not multipost!
 
Thank you for your reply.
I am new to some of the terms and would appreciate any help.
What is polling? Would this be looping through all the keycodes?
If I were to try trapping a message and looking for a keycode,
wouldn't this only give me one keycode at a time?
If they are pressing 20 keys simultaneously I would need to know them all.
Thanks again.
 
You have the KeyPress event which provides you the means to obtain
keystrokes. If you wanted more, you will have to wait till i try it out.

with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 
Back
Top