|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
OnKeyPress
I'm making a game for my computer science class. How do I have an event occur when certain keys are pressed? ie. spacebar, z, and arrows
__________________
www.xoise.com - www.ourfreegames.com - www.g1games.com - www.randomtools.net - www.xenocide-rpg.com - Lyrics Search Engine |
|
#2
|
|||
|
|||
|
In VB6 in the keyup, keydown, keypress event for a control or form you can test the actual keycode value and do whatever if the key pressed is one of the keys you're interested in.
I don't think you can cause the event only on certain keys.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
||||
|
||||
|
|
|
#4
|
|||
|
|||
|
The best example is found in the VB documentation. In the VB IDE open Help and look for the documentation for the desired control, then locate the documentation for the various keypress events. Example code is found there.
|
|
#5
|
||||
|
||||
|
We have a sample version of VB at school, so it doesn't have the help area.
|
|
#6
|
|||
|
|||
|
For vb6 try looking in the online documentation, for example here is the documentation for a textbox control keypress event
http://msdn.microsoft.com/library/e...evtkeypress.asp |
|
#7
|
|||
|
|||
|
Check the last function on this page.
http://vb-tec.de/inkey.htm ![]() Just do a loop or a timer to do the check |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > OnKeyPress |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|