I am trying to write a piece of code so that when a key is pressed it will execute something, but then the key will have to be released and then repressed again in order to retrigger the event. So if the user just holds down the key, it wont keep doing it over and over, instead they will have to press and release repeatedly.
So far, I have:
if(keyLifted)
{
if(Keyboard.isKeyDown(45))
{
keyLifted = false;
dostuff;
}
else if(Keyboard.isKeyDown(46))
{
keyLifted = false;
dostuff();
}
else
{
keyLifted = true;
}
}
but this is flawed for obvious reasons (it will only reset the key to being unlifted if the key is already lifted: if the key was pressed, it wont be set to unpressed). I have tried a couple variations, but I just cant get it to work.
Thanks in advance for any help!