Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Multiple Key Handling- Just Cant Cope?

Author
Message
CKy
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location:
Posted: 1st Mar 2004 08:25
Hey. whilst trying to make a FPS i noticed that i cant press 2 keys at once. So i cant strafe/foward etc. How do you get scancode() to pick up two keys simultaneously?
I'd post my code, but its reaaally long and messy <-- cause its a 'test' thing to see what i can and cant do
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 1st Mar 2004 09:49
First of all, someone posted this pic before. This pic may be useful:


http://www.freewebs.com/kabouter/scancodes2.png

scancode() only returns the scancode number of the button being pressed, so it can only check one button at a time. But if you use keystate() and pass a scancode number to it as a parameter, it will check if that scancode is being pressed and return a 1 if it is, and if not it will return a 0. So keystate(17) returns a 1 if the 'w' key is pressed. This way, you could use multiple keystate() functions and use them to flag variables so you can check them later.



Strangely, my keyboard will only respond up to 3 key simultaneous keypresses. Dunno if other people have the same problem.

CKy
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location:
Posted: 1st Mar 2004 10:15
wow. thats useful.
thx man

Login to post a reply

Server time is: 2024-11-26 07:44:13
Your offset time is: 2024-11-26 07:44:13