You can use something like:
bool key_triggered[sf::Keyboard::KeyCount]; //array containing all possible keys
void resetTriggered()
{
for (int i = 0; i < sf::Keyboard::KeyCount; ++i)
key_triggered[i] = false;
}
//initialize!
ResetTriggered();
bool isKeyTrigger(sf::Keyboard::Key key)
{
if ( sf::Keyboard::isKeyPressed(key) && !key_triggered[key] )
{
return (key_triggered[sf::Keyboard::Right] = true);
}
}
Now, you can use it like this.
if (isKeyTrigger(sf::Keyboard::Right)) //your choice of key
{
//example: move character right!
}
//must update after end of key-check loop!
resetTriggered();
This is a simplified version; you can insert the variables and fuction inside a class to make it more uniform.
Also, note that you can check for the same key ONLY ONCE per frame/tick.