Stop or cancel movement if the player hits wall.

hello, I’m having a pretty annoying problem that I’ve tried everything in my skill-set. from be it 2D ray-casting(which didn’t work because i need the box collider for triggers) to collision detection even just really complex nested if statements but Im still at square one with this problem.
125993-3bd784074bb7f62d156a9447539f4474.png

here is how its supposed to go

1: player presses direction

2:player moves in that direction(while avoiding the circle antagonist who is paroling)

3:players collider hits the trigger on the key

4: player unlocks door

5:player reaches goal

now everything else works but when the play hits a wall it will jitters back and forth here is my code and why it does that:

//Inspector Variables

public bool Key = false;

Vector3 pos;                                // For movement
float speed = 2.0f;                         // Speed of movement

void Start()
{
    pos = transform.position;          // Take the initial position
}

void Update()
{

    //
    if (Key == true)
    {
        this.tag = "Key";
    }
    else
    {
        this.tag = "Player";

    }

   
}

void FixedUpdate()
{

    if (Input.GetKey(KeyCode.A) && transform.position == pos)
    {        // Left
        pos += new Vector3(-1.5f, 0, 0);
    }
    if (Input.GetKey(KeyCode.D) && transform.position == pos)
    {        // Right
        pos += new Vector3(1.5f, 0, 0);
    }
    if (Input.GetKey(KeyCode.W) && transform.position == pos)
    {        // Up
        pos += new Vector3(0, 1.5f, 0);
    }
    if (Input.GetKey(KeyCode.S) && transform.position == pos)
    {        // Down
        pos += new Vector3(0, -1.5f, 0);
    }
    transform.position = Vector3.MoveTowards(transform.position, pos, Time.deltaTime * speed);

}

as you can see i use grid based movement, and keep it at a nice steady pace when it hits a wall(tagged Wall). It will continually try to push through the wall causing that jitter. This stops all movement.
sorry for asking for a simple thing i know its a little embarrassing but I’m still trying to learn code.

How can I have it realize its hitting a wall and return to the last position or just cancel out the movement command all together

thank you in advance

(I should add those white boxes aren’t individual but one big sprite grid)

this is still a problem idk what to do

Are you using tiles? An array/grid?

If you have something that is holding your grid spaces just check to see if the intended move-to grid space is open before setting pos.

Second: you can wrap everything in the fixedupdate into a single if statement

 if(this.pos == pos)
    {
    Keychecks
    }
    else
    {
    moveto
    }