sf::Keyboard gives the current state of key, regardless of when it was pressed or since how much time.
Assuming your game runs at 60FPS, then your game loop runs at about 60 times per second, so when you press a key for exactly 1 second, this code
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
moveLeft();
}
is called 60 times and so your character moves 60 steps.
What you actually need is to use
sf::Events, a sample code would be :
sf::Event event;
while (mWindow.pollEvent(event)) {
if (event.type == sf::Event::KeyPressed) {
sf::Uint32 keyCode = event.key.code;
if (keyCode == sf::Keyboard::Left) {
moveLeft();
}
else if (keyCode == sf::Keyboard::Right) {
moveRight();
}
else if (keyCode == sf::Keyboard::Up) {
enterRoom();
}
}
else if (event.type == sf::Event::Closed) {
mWindow.close();
}
}
In this code, our functions are only called the moment when the keys are just pressed, so in order to activate them again, one must release the key then press it again. So instead of asking the keyboard : "Hey, is the left key currently pressed?" we ask him "Hey, did the player just press the left key this frame?"