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.

DarkBASIC Professional Discussion / Multiple key presses!

Author
Message
Ian T
23
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 29th May 2003 23:03
I do feel rather guilty bombarding this forum with questions, but I'm still quite rusting with my coding (notice lame excuse for lake of knowledge)...

How can one check for multiple keypresses in one loop? Scancode() and Inkey$() naturally only return one key. But it's a real nuisance, as I'm sure anyone who has tried to make a first person game knows, to stop moving forward when you strafe, stop running when you press Use, etc.

What's da key?

Thanks
--Mouse

Famous Fighting Furball
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th May 2003 23:29
Use KEYSTATE().

You are probably using something like this to detect keypresses:

if scancode() = 2 then ` '1' pressed.

Detecting the same key using keystate works like this:

if keystate(2)=1 then ` '1' pressed.
Ian T
23
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 29th May 2003 23:32
Thanks IanM.

Amusingly enough, I never did know that... after all these years.

Shows what I've coded

Much obliged

--Mouse

Famous Fighting Furball

Login to post a reply

Server time is: 2026-07-11 11:42:31
Your offset time is: 2026-07-11 11:42:31