How to change and change back gravity?

I’m very new to coding and unity2d as a whole. I am trying to make my character glide if the player is holding down space by lowering the gravity. So how would I change the gravity back after lowering it? Thanks!

public class Glide : MonoBehaviour
{
private Rigidbody2D rb;

void Start()
{
    rb = GetComponent<Rigidbody2D>();
    rb.gravityScale = 2;
}

void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
    {
        rb.gravityScale = 1;
    } else if (rb.gravityScale != 2);
    {
        rb.gravityScale = 2;
    }
}

}

Hi,
I think you may want to use a
Input.GetKeyUp(KeyCode.Space))

in place of the “else if”
Then I don’t work with rigidbodies so not sure for the gravity scale.
But the key up should help.
Hope that helps