Don't do it like this. You should rather check for the four main directions, and add their contributions to a velocity vector.

const float speed = ...;

sf::Vector2f v;

if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))

v.y -= speed;

if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))

v.y += speed;

if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))

v.x -= speed;

if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))

v.x += speed;

Then, you can still address the problem that diagonal movement leads to a higher speed, just divide by the square root of 2 in this case.

if (v.x != 0.f && v.y != 0.f)

v /= std::sqrt(2.f);

The object is eventually moved by an offset which equals to the velocity multiplied with the passed time.

sf::Time dt = ...;

object.move(v * dt.asSeconds());

To compute the angle, you can use

`std::atan2()`. Please refer to

www.cppreference.com for more details.