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 / Release Key?

Author
Message
Radio Check
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 25th Sep 2004 01:50
I am using arrow keys to move pieces on a board game but I don't want the keypress to repeat. IOW, I only want the marker to move one space no matter how long you hold down the key, and not move again until you release the key and press it again.

I don't find a release key command, and I have tried various ways of making a variable that needs to be changed but none of them seem to work well.

Thanks in advance.

Making a cool sig is just too much pressure for me right now.
Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 25th Sep 2004 02:12 Edited at: 25th Sep 2004 02:13
keypress=0
do
if leftkey()=1 and keypress=0
keypress=1
stuff..........
endif

if scancode()=0 then keypress=0

stuff
stuff
stuff

loop


The word "Gullible" cannot be found in any English Dictionary.
Radio Check
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 25th Sep 2004 02:30
Quote: "if scancode()=0 then keypress=0
"


Aha! All I had to do was put the "if scancode()=0" part in front of what I already had.

Thanks for the quick answer!

Making a cool sig is just too much pressure for me right now.
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 25th Sep 2004 02:37
I use the exact same method, oh, I hoped i finally could help someone
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 26th Sep 2004 18:56 Edited at: 26th Sep 2004 18:57
Here's the method I use in most of my programs, it allows for Press, Hold, and release of keys.

The following example is for the right-mouse button.



To use it for different keys, just change the first line to something like:
If LeftKey() = 1
etc.
And for each new key you add, just put in a new variable up top to hold the press state, and change the variable in the code

Jess.


Team EOD :: Programmer/All-Round Nice Guy
Aust. Convention!

Login to post a reply

Server time is: 2024-09-23 00:26:49
Your offset time is: 2024-09-23 00:26:49