As long as the key is held down you're going to have a positive result each time through your loop. You might need to maintain a boolean flag to track if the key press has already been detected. If it has, ignore any of that key press until it's released at which time you reset the boolean to false and it lets you detect the next time the key is pressed. Since you're using functions to check for the key press it would be easy to have each checkXXXX function contain a boolean as a static variable so it retains its value from one function call to another
bool checkRight()
{
static bool pressed = false; // initially not pressed
if (!pressed) { // if not previous pressed
if (dbRightKey() == 1) {
pressed = true;
return true;
}
} else { // if we got here then the key was previously pressed
if (dbRightKey () == 1) { // key still down?
return false; // no second press yet
} else { // it's been released
pressed = false;
return false; // still no new press
}
}
}
There's still some fault with this code since it may depend on when and where in the code it gets called. But if it's in a fairly tight loop it should be okay for your purpose. Now you have to modify the code for the other four functions.
Lilith, Night Butterfly
I'm not a programmer but I play one in the office