How can I move my player up until the jusmp button is let go?

How can I make my player object go up when a key is held, then it falls down when it’s let go in 2D.

@UnityCoach
]

To handle the jump state, you can do this:

[SerializedField] Keycode jumpKey;

public bool jumping {get ; private set;}

void Update ()
{
    if (Input.GetKeyDown (jumpKey))
        jumping = true;
    else if (Input.GetKeyUp (jumpKey))
        jumping = false;
}

Then, you can use Transform component, AnimationCurve, Animator, RigidBody2D, there are many ways you can make a character jump.