How do i rotate based on direction character is moving in

For example, when I press D and the char moves right, I want the model to turn right. I tried this code but the model never stops moving for some reason. Also, it doesn’t do like a diagonal turn when you press two keys like forward and right, which is what i want.

using UnityEngine;
using UnityEngine;
using System.Collections;

public class move2 : MonoBehaviour {
	
	private Quaternion rotD;
	private Quaternion rotA;
	private Quaternion rotW;
	private Quaternion rotS;
	private Vector3 move;
	private float v, h;
	public CharacterController cc;
	public float hSpeed, vSpeed;
	
	// Use this for initialization
	void Start () {
		//cc = GetComponent<CharacterController> ();
		rotD = Quaternion.Euler (0,90,0);
		rotA = Quaternion.Euler (0,-90,0);
		rotW = Quaternion.Euler (0,0,0);
		rotS = Quaternion.Euler (0,180,0);
		move = new Vector3 ();
		
	}
	
	// Update is called once per frame
	void Update () {
		
		float v, h;
		if (Input.GetKeyDown (KeyCode.D)) 
		{
			h = Input.GetAxis("Horizontal");
			move.x = h * hSpeed;
			transform.rotation = rotD;
		}
		if (Input.GetKeyDown (KeyCode.A)) 
		{
			h = Input.GetAxis("Horizontal");
			move.x = h * hSpeed;
			transform.rotation = rotA;
		}
		if (Input.GetKeyDown (KeyCode.W)) 
		{
			v = Input.GetAxis("Vertical");
			move.z = v * vSpeed;
			transform.rotation = rotW;
		}
		if (Input.GetKeyDown (KeyCode.S)) 
		{
			v = Input.GetAxis("Vertical");
			move.z = v * vSpeed;
			transform.rotation = rotS;
		}
		
		cc.SimpleMove (move);
		
	}
}

Hi
first of all before I start I have to say
navigate to Edit>Project setting>Input
then make both Horizontal and Vertical Gravity to “1”
ok
I have written a script to do exactly what you want
just assign it to your GameObject you want to move.
the movetype of the script have to be on WorldAxis however local is another common character move type you may like.

using UnityEngine;
using System.Collections;

public class move2 : MonoBehaviour
{
	public enum MoveType
		{
		worldAxis,
		localAxis
		}
	public MoveType moveType;
	public float moveSpeed = 1.0f;
	public float rotationSpeedOnLocalAxis = 15.0f;
	float angle;
	float x;
	float z;

	void Awake()
	{
		StartCoroutine ("ChildManager");
	}

	void Update ()
	{
		//
		x = Input.GetAxis ("Horizontal")*moveSpeed;
		z = Input.GetAxis ("Vertical")*moveSpeed;
		if(moveType == MoveType.worldAxis)
		{
			transform.position = new Vector3 (transform.position.x+x, transform.position.y, transform.position.z+z);
		}
		else
		{
			transform.Rotate(transform.up,x*rotationSpeedOnLocalAxis);
			transform.Translate(0.0f,0.0f,z*100.0f*Time.deltaTime,transform);
		}

	}

	IEnumerator ChildManager ()
	{
		GameObject go = new GameObject("follower");
		go.transform.position = transform.position - new Vector3 (transform.position.x, transform.position.y, transform.position.z - 1.0f);
		for(;;)
		{
			go.transform.position = new Vector3(Mathf.Lerp(go.transform.position.x,transform.position.x,moveSpeed*100.0f*Time.deltaTime),
			                                    Mathf.Lerp(go.transform.position.y,transform.position.y,moveSpeed*100.0f*Time.deltaTime),
			                                    Mathf.Lerp(go.transform.position.z,transform.position.z,moveSpeed*100.0f*Time.deltaTime));
			angle = Vector3.Angle(go.transform.position,transform.position);
			Debug.DrawLine(go.transform.position,transform.position);
			if(moveType == MoveType.worldAxis)
			{
				transform.LookAt(go.transform);
			}
			yield return null;
		}
	}
}