How to stop Character from speeding up

So I am working on my first 3d project, but my character keeps picking up speed when I hold the movement key down.
I need help making the character stay at the same speed when a button is pushed.
Here’s the Code:

public int speed;
public int jumpForce;
public Transform player;
public Rigidbody rb;

void Update() {

void FixedUpdate()
    if (rb.velocity.magnitude < .01) {
       rb.velocity =;
    if (Input.GetButton("Vertical")) {
        rb.AddForce(0, 0, Mathf.Round(Input.GetAxis("Vertical")) * speed * Time.deltaTime, ForceMode.Impulse);
    if (Input.GetButton("Horizontal")) {
        rb.AddForce(Mathf.Round(Input.GetAxis("Horizontal")) * speed * Time.deltaTime, 0, 0, ForceMode.Impulse);
    if (Input.GetButton("Jump")){
        if (canJump == true) {
            rb.AddForce(0, jumpForce, 0);

Try using GetButtonDown. GetButton checks if it is currently pressed, but Down should only happen when it is pressed initially. You can set the force back to zero on GetButtonUp as well. Hope that helps!

Maybe you can use the Clamp method to limit your RigidBody velocity to a certain value. Probably something like Vector2.ClampMagnitude(rb.velocity, maxMagnitude) should work for you, just put it at the end of the FixedUpdate.

While your user holds the button, Force is being added every frame :S If you want to keep the forces, you need a flag “bool wasForceAdded” that is set to true as soon as you add the force. Before you add force to character, check if force was added. If it was, DO NOT add. This will prevent the force to be added on the next frame. Have the flag set to false when button is released.