How to change object rotation on button press then have it revert afterwards

I’m trying to recreate flappy bird. I have the wing object attached to the bird object, but i want to make it so every time i press spacebar, the wing moves down- then goes back to it’s original position to look like it’s flapping. But i’m just completely stumped. This is the code i have so far.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Birdwingright : MonoBehaviour

{
    public bool WingFlapDown = true;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

        if (Input.GetKeyDown(KeyCode.Space) == true)
            transform.Rotate(new Vector3(-1, 0, 0));
        
    }
}

update- I figured out how to rotate the wing every button press. But it rotates around in a circle. How do I lock it to moving in one position, then reverting to the original position?

check some tutorials about animations in unity.

in short you add a animator controller then animate the character by adding keyframes to the rotation of those wings. You can then tweak the ease and timing and everything. Then you can trigger that animation in code when pressing the space bar.

It can also be done in code using the default unity ease or using the DoTween free assets (for example you can use the yoyo option to get it back and forth)