Rigidbody2D Force.Impulse Doubled

This is a neat issue, I don’t really understand. It only happens whenever I’m walking, but on occasion, my Y velocity will be double the intended amount whenever I press the jump button.

using UnityEngine;

public class InGameControls : MonoBehaviour {

    float keyboardMoveSpeed = 150.0f;
    public float jumpPower = 5.0f;
    public Rigidbody2D playerRigidbody;

    //There's a regular box collider 2D used by the player
    //and an additional one at the feet that's a trigger, not overlapping.
    void OnTriggerStay2D() {
        if (Input.GetKey(KeyCode.Space)) {
            playerRigidbody.AddForce (transform.up * jumpPower, ForceMode2D.Impulse);
        }

        if (!Input.anyKey && playerRigidbody.velocity.y == 0) {
            Vector2 temp = new Vector2 (0, playerRigidbody.velocity.y);
            playerRigidbody.velocity = temp;
        }
    }

    void Update() {
        if (Input.GetKey(KeyCode.A)) {
            playerRigidbody.velocity = new Vector2(-keyboardMoveSpeed * Time.deltaTime, playerRigidbody.velocity.y);
        }

        else if (Input.GetKey(KeyCode.D)) {
            playerRigidbody.velocity = new Vector2(keyboardMoveSpeed * Time.deltaTime, playerRigidbody.velocity.y);
        }
    }
}

Edit: Updated code to reflect current state.

Don’t do inputs in FixedUpdate, it isn’t guaranteed to fire regularly. It can fire twice or not at all. Inputs should be gathered in Update only, and this advice is given everywhere.

Next, I don’t see any conditionals in Stay which says “don’t do this, I’m already jumping”.

Sorry, I haven’t been everywhere. ^^ I hadn’t heard that one. I’ll be sure to manage those ones in Update.

It’s based on the trigger itself, whenever the player jumps, the trigger is no longer in range. They leave range after a few frames of jumping. Should I instead check if the y velocity is 0, to prevent any jumping when it’s already happening?

Edit:
I set it so you can’t jump unless the trigger is in range and the velocity is 0, and change FixedUpdate to Update. It still happens. Actually I found that if you stop holding a direction in the air right after the double height happens, whatever causes the issue will be stuck in effect and will repeat 100% of the time until you move on the X axis again.

After more troubleshooting, I’ve figured out that it happens when I’m overlapping two colliders with my trigger. Any way to avoid doubling up the effect?

Edit:
I’ve added this stipulation and it works, but I’m hoping for a more elegant solution. Thanks!

if (playerRigidbody.velocity.y > jumpPower) {
    Vector2 temp = new Vector2 (playerRigidbody.velocity.x, jumpPower);
    playerRigidbody.velocity = temp;
}