Cube Rotation

Unity forum,

Hello everyone I’m stuck in a predicament and I was needing some advice or somebody willing to get me in the right direction with moving a cube. I’m trying to create a very basic platform mini game where the user can press any movement key such as W, A,S,D key and it will flip the cube in that respected position. The W key would make the cube flip North, the D key would flip the cube South etc…
The only issue I’m having is the key presses has to be continuous pressed a few times to get the cube to flip over and snap flat without bouncing or moving slightly. Is there any Unity API that could help me figure this out or anyone know a simple solution? Any help or recommendations would be greatly appreciated. I’ve included the script for what I currently have working at the moment.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class test : MonoBehaviour
{

    // Use this for initialization
    void Start ()
    {
       
    }
   
    // Update is called once per frame
    void Update ()
    {
        if(Input.GetKeyDown(KeyCode.D))
        {
            GetComponent<Rigidbody>().angularVelocity = new Vector3 (90, 0, 0);       
        }
        if(Input.GetKeyDown(KeyCode.A))
        {
            GetComponent<Rigidbody>().angularVelocity = new Vector3 (-90, 0, 0);       
        }
        if(Input.GetKeyDown(KeyCode.W))
        {
            GetComponent<Rigidbody>().angularVelocity = new Vector3 (0, 0, 90);       
        }
        if(Input.GetKeyDown(KeyCode.S))
        {
            GetComponent<Rigidbody>().angularVelocity = new Vector3 (0, 0, -90);       
        }
    }
}

I’ve proposed a solution to this problem a while ago. Have a look at this post.