The more I press a button the farther my object goes : How can i make it

I tried to create a game,
when the player push a button the ball start to charge herself (without moving) and when the button is released the ball is thrown away in proportion to the time it was charged.

I have something like this :

using UnityEngine;

public class movement : MonoBehaviour

{
    public Rigidbody rb;
    private float force = 0;

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.G))
            {
            force = force + Time.deltaTime;
        }
        if (Input.GetKeyUp(KeyCode.G))
        {
            rb.AddForce(force, 0, 0);
        }
            
    }
}

If anyone has a idea?

You want to use if (Input.GetKey(KeyCode.G))

GetKeyDown only registers once – when the key is first pressed. GetKey will add as long as the key is pressed.