if (e.type == Event::KeyPressed && e.key.code == Keyboard::Z && e.type == Event::LostFocus){
Do you really think the variable e.type can have both Event::KeyPressed and Event::LostFocus values at the same time? ;)
If you want to detect a key pressed while the window doesn't have the focus:
if (e.type == Event::KeyPressed && e.key.code == Keyboard::Z && !window.hasFocus()){
If you want to detect a key pressed while the window doesn't have the focus:
if (e.type == Event::KeyPressed && e.key.code == Keyboard::Z && !window.hasFocus()){
Except, events won't trigger if the window doesn't have the focus.
You can use sf::Keyboard::isKeyPressed() to check the key state, but I wonder what you're trying to do that you want to process keyboard inputs when your window doesn't have focus.