coding object movement help

Hello, I’m trying to code an object that moves UP/DOWN/LEFT/RIGHT on a flat surface, no diagonal. I’m using a basic if statement like this:

if(Input.GetKey("a"))
{
//moveLeft
}
else
if(Input.GetKey("w"))
{
//moveUp
}
else
if(Input.GetKey("d"))
{
//moveRight
}
else
if(Input.GetKey("s"))
{
//moveDown
}

The problem is that I want the order in which the keys are pressed to not matter. Right now, if I press W(up) while holding A(left), the object ignores W and keeps moving left because it’s the first in the if statement. On the other hand, if I press D(right) while holding S(down), the direction changes and the object moves right. If I let go of D(right), the object goes back to moving down; This last bit is how I want all the keys to react. How do I fix this in code? Any help would be great, thanks!

private float moveLeftRight=0;
private float moveUpDown=0;

in Update:

// GetKeyDOWN gets the key once when it is pressed. So, you ever get the "newest" key.
if(Input.GetKeyDown("a"))
{
  moveLeftRight= - 1.0f;
  moveUpDown=0.0f;
}

if(Input.GetKeyDown("d"))
{
  moveLeftRight= 1.0f;
  moveUpDown=0.0f;
}

if(Input.GetKeyDown("w"))
{
  moveLeftRight=0.0f;
  moveUpDown= - 1.0f;
}

if(Input.GetKeyDown("s"))
{
  moveLeftRight=0.0f;
  moveUpDown= 1.0f;
}

// Maybe reset the values.

// GetKeyUP gets the key once when it is released.
if(Input.GetKeyUp("a") && moveLeftRight== - 1.0f)
{
  moveLeftRight=0.0f;
}

if(Input.GetKeyUp("d") && moveLeftRight== 1.0f)
{
  moveLeftRight=0.0f;
}

if(Input.GetKeyUp("w") && moveUpDown== - 1.0f)
{
  moveUpDown=0.0f;
}

if(Input.GetKeyUp("s") && moveUpDown== 1.0f)
{
  moveUpDown=0.0f;
}

// (NO if)
//move left or right (X += speed * moveLeftRight);
//move up or down (Y += speed * moveUpDown);

I hope that helps. Not tested.