PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

press and hold the keys

(sorry for posting twice, I posted the first time without logging in, plz ignore the post from 'Guest')

Greetings.
I'm using PocketPC(2003 and Jam)
When I use KeyDown, I have to repeatedly press the keys. I'd like to press and hold the keys on the PPC and have the application respond.

thank you

awni
What you need to do is set a state variable, and check it.

For example, make the following boolean array:
bool bKeyDown[8];

Add add this in KeyDown:
bKeyDown[KEY_RIGHT] = true;
// or LEFT, UP, DOWN, A, B, C, etc

And this in KeyUp:
bKeyDown[KEY_RIGHT] = false;

Then you can check the bKeyDown array.
that's the idea i'm using right now, i used variables instead of an array, but i get the same result. I was looking for an alternative. Something that will continously call a function while a key is down. If no such method exists, that's ok, i'll use your array approach...

thank you

awni
Presto's suggestion is the accepted practice. You shouldn't do any heavy processing within KeyUp/KeyDown as you want these to return as quickly as possible. Set your flags in these methods and process them (ie call your functions) within ProcessNextFrame.
thanks
I'll be doing that...and I'll be posting a second question...

awni