How do i rotate a gameobject

EXAMPLE: everytime i press/hold ‘D’ the player turns 90 degrees right and moves in that direction if held (like i want it to) but when i press ‘D’ again it will turn 90 degrees again so the gameobject would be 180 degrees from its starting rotation. Same with pressing A for the left. But this ‘S’ it turns 180 degrees and when pressed again it will turn back to the starting position. How do I make it that once the object is at that rotation e.g 90 degrees, every time ‘D’ is press again instead of turning 90 degrees again, Just move forward in that direction. Here is my code:

using UnityEngine; 
using System.Collections;

public class Playermisc : MonoBehaviour {

public GameObject maincamera;
public GameObject player;
public float turnSpeed = 1.0f;
public float time = 1f;
public float speed = 1f;
public GameObject Leg;
 
 
// Use this for initialization
void Start () 
{
    animation.Play("Standing");
    animation["Jump"].speed = 1.3f;
    animation["Falling"].speed = 0.42f;
    Screen.lockCursor = true;
}
 
// Update is called once per frame
void Update () 
{   
 
 
 
    if(Input.GetKeyDown(KeyCode.Escape))
    {
     player.GetComponent<MouseLook>().enabled = false;
     maincamera.GetComponent<MouseLook>().enabled = false;
    }
 
    if(Input.GetMouseButtonDown(0))
    {
     Screen.lockCursor = true;
     player.GetComponent<MouseLook>().enabled = true;
     maincamera.GetComponent<MouseLook>().enabled = true;
 
    }
 
    if(Input.GetKeyDown(KeyCode.W))
    {
       animation.CrossFade("Run");
    }
    if(Input.GetKeyUp(KeyCode.W))
    {
       animation.CrossFade("Standing");
 
    }
    if(Input.GetKeyDown(KeyCode.D))
    {
       animation.CrossFade("Run");
       transform.Rotate(0,90,0);
    }
    if(Input.GetKeyUp(KeyCode.D))
    {
       animation.CrossFade("Standing");
 
 
    }
    if(Input.GetKeyDown(KeyCode.A))
    {
       animation.CrossFade("Run");
       transform.Rotate(0,-90,0);
 
    }
    if(Input.GetKeyUp(KeyCode.A))
    {
       animation.CrossFade("Standing");
 
 
    }   
if(Input.GetKeyDown(KeyCode.S)) { animation.CrossFade("Run"); transform.Rotate(0,180,0); } if(Input.GetKeyUp(KeyCode.S)) { animation.CrossFade("Standing");

    }
 
    if(Input.GetKeyDown(KeyCode.Space))
    {
       animation.CrossFade("Jump");
       if(animation.IsPlaying("Jump") == false)
       {
         if(Input.GetKeyDown(KeyCode.W))
         {
          animation.CrossFade("Run");
         }
       }
 
 
    }
 
 
}
}

Try this:

Replace line 55:

transform.rotation = Quaternion.LookRotation(Vector3.right);

Insert below just above line 45:

  transform.rotation = Quaternion.LookRotation(Vector3.forward);

Replace line 66:

 transform.rotation = Quaternion.LookRotation(Vector3.left);

On line 75, replace the Rotate() with:

 transform.rotation = Quaternion.LookRotation(Vector3.back);