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 Discussion / Keyboard Key Hold-down?

Author
Message
gh0u1
21
Years of Service
User Offline
Joined: 24th Apr 2004
Location:
Posted: 28th Apr 2004 08:31
Okay, okay. I know I've been bugging the forums lately, and it seems like I haven't been doing any coding on my own, and for this, I'm very sorry. The fact is, I'm pestered easily by tedium, at least tedium that I find difficult to eliminate. This is just a simple question that I'm sure I used to know how to do.

There's a prompt in my code for the user to hit a key for something.
Example:

If scancode(18)=1 then in var,1

How can I set it so that I can press and hold down that key but only have var increase once, as opposed to once for every tenth of a second that I'm holding it? Essentially, I want key presses to only react once per press. Thanks, all!
zane
21
Years of Service
User Offline
Joined: 23rd Feb 2004
Location: manchester, england
Posted: 28th Apr 2004 12:27
try


That should do it

www.zaneinteractive.uni.cc - my brand new site, check it out - NOW!!!!!
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Apr 2004 22:54
You use what is called a flag. A flag is most commonly a boolean variable, in other words, its value is either TRUE or FALSE.

The flag is down.
flag = 0
The flag is up.
flag = 1





What this means is, if the flag is up, it signals that the operation is currently taking place. In this example, a button being pressed. When the button is released, the flag stops signalling, saying that the button has not yet been pressed.

"eureka" - Archimedes
gh0u1
21
Years of Service
User Offline
Joined: 24th Apr 2004
Location:
Posted: 28th Apr 2004 23:17
I remembered it being something along those lines, but when I tried it, I just created another variable that increased at a ridiculous pace.

Thanks a ton, everybody, and thank you Phaelax, for responding to my other posts. You're very helpful.

Login to post a reply

Server time is: 2025-05-23 11:48:44
Your offset time is: 2025-05-23 11:48:44