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 / Delays while pressing keys

Author
Message
DaedalusX
21
Years of Service
User Offline
Joined: 10th Mar 2004
Location:
Posted: 13th May 2004 01:21
im trying to do something which i think is simple but i cant work out what code to use. i use normal darkbasic and what im trying to do is when u press a key with the code if controlkey() etc i want it to register it as one ress and not continuos as if i press iot and let go it goes through several cylces.

thanx
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 13th May 2004 01:59
so basically "one-touch" right:


if keystate(17) = 1
if key = 0
key = 1
// "one time" code goes in here
endif
else
key = 0
endif


basically, the variable "key" is always set to 0 until you hit the key. When you hit the key, it checks to make sure key is at 0, the sets it to 1 and executes the code below it. So unless you release your hand from the button, key won't become 0 and the code won't be executed again.

HIH

BadMonkey91
21
Years of Service
User Offline
Joined: 13th Jan 2004
Location:
Posted: 13th May 2004 17:00
expample:


whatever you're doing, I'm sure it's more complex, but it'll work just the same. It detects if the buttons released.

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th May 2004 19:07 Edited at: 13th May 2004 19:08
Badmonkey, you need to make a block out of your IF clause for it to work, otherewise "hit=1" will always run...



BatVink
http://facepaint.me.uk/catalog/default.php AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
DaedalusX
21
Years of Service
User Offline
Joined: 10th Mar 2004
Location:
Posted: 13th May 2004 19:08
ok thanx both of u thats what i need exept i couldnt find out which key was to be pressed in the keystate. ill work on it.
WhizzRich
22
Years of Service
User Offline
Joined: 30th Nov 2002
Location:
Posted: 13th May 2004 21:20
If you need to do this a lot, then check out my code snippet in the CodeBase. It makes it a lot tidier.

Hopefully this link will work..

http://darkbasic.thegamecreators.com/?m=codebase_view&i=fdbe8d64626493833e10d082f7704731

It also has a picture of a keyboard with all the ASCII values.

WhizzRich ---

Login to post a reply

Server time is: 2025-05-23 19:48:16
Your offset time is: 2025-05-23 19:48:16