So, basically, you have a boolean value: isInAir.
You're gonna want to set isInAir to true when you press space. Each frame, check wether your boolean is set to true. If that's the case, update the position of the rectangle according to the velocity and gravity:
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
{
isInAir = true;
}
if(isInAir)
{
velocity += gravity * deltaTime;
rect.move(velocity * deltaTime);
}
(The delta time is the time that the last frame took to execute).
Finally, set your isInAir value to false when a collision with the ground is detected.
if(collisionDetected(rect, ground)) // Your collision detection algorithm
{
isInAir = false;
}
Keep in mind that this may not be 100% accurate (it lacks things like acceleration and such) but that's the basics anyway.
Also, you may wanna fix your timestep (
gafferongames.com/game-physics/fix-your-timestep/%22). It makes the whole physics handling a lot easier. With this technique, no need for any deltaTime values anymore.