Yes, as ZeroZ30o says, simply overwrite a variable on key presses. Unless you have your graphics and input strictly separated, you could also use sf::Vector2, as saves you from an extra case differentiation:
if (event.key.code == sf::Keyboard::Left)
direction = sf::Vector2f(-1.f, 0.f);
...
// multiply with speed later
Yeah, everytime you press a key make it overwrite a variable.
So for instance, when you press right, you set
direction = "right"
and then after that if you press left you overwrite with
direction = "left"
And when you release a key you can check which keys are still pressed and overwrite with one of them, or alternatively you can store the overwritten keypress on an array and release them back in order. But this is a bit overdoing it.
This is about the same method that I have been trying to use, but instead I used bool's to hold the keys. The problem is if I were to do like this for example:
if(Key == Left)
direction = left;
if(Key == Up)
direction = up;
if (Key == Down)
direction = down;
if (Key == Right)
direction = right
Now if I hold right, and then press down, the direction will remain right since it's always the last statement. The keys that are on top will be able to use the directions under them (for example left can change to all directions, while right can't change at all) but not the other way around.