Player Stuck Moving

I’ve been having this weird problem in Unity where my player keeps moving forward and left as if the W and A keys were stuck. This issue occurred in 2 microgames, the universal render pipeline, and a 2D game with custom code (player just moves left in 2D). I am still able to move the player, but if I let go of keys, it continues to move. In the microgames and pipeline, the problem was only solved if I clicked “maximize on play” then stop and restarted the game. I had no problem playing these same microgames on a different PC. In the 2D game, the issue would stop the second time I tested the game, but if I switched windows and game back, the player would move as soon as I started the game (without me pressing anything). This would occur even if my keyboard and mouse was unplugged. I have also tried reinstalling Unity and Visual Studio as well as restarting my PC. I don’t think the issue is with the code or my peripherals, and I have no idea what else it could be.

I would really appreciate some help!

Here is the code from the 2D game if you wanted:

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
   public float speed;
   private Rigidbody2D body;

    private void Awake()
    {
        body = GetComponent<Rigidbody2D>();
    }

    private void Update()
    {
        body.velocity = new Vector2(Input.GetAxis("Horizontal") * speed, body.velocity.y);

        if (Input.GetKey(KeyCode.Space))
            body.velocity = new Vector2(body.velocity.x, speed);

    }

}

Please don’t cross post. You’ve posted this issue several times now. You got a reply here .