LostFocus and GainedFocus can solve your problem but you will have to track the focus state to know whether it's currently in focus or not (it would only need a simple boolean, of course).
However, and especially since you're using real-time states, you may also be interested in hasFocus (https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1Window.php#ac4dce670f07c5039a732ba0903ce3a77), which can inform you of the current state of focus.
e.g.
if (window.hasFocus())
{
if (isKeyPressed(sf::Keyboard::Up))
moveUp();
if (isKeyPressed(sf::Keyboard::Down))
moveDown();
// etc.
}