I need some help with this script...

Hello. I am trying to use this script to rotate an object by -120 degrees every time the “a” button is pressed, but, have it take a certain amount of time.
I also want to have the object rotate 120 degrees when the d button is pressed. The problem is, if I press the a button while the object is still rotating from when I pressed, the object rotates 120 degrees from where it was when the button was pressed. How can I have the rotations only work when the object is done rotating (so when the object is at a rotation of 0, 120 and 240)? Thanks

function Update(){
	if (Input.GetKeyDown("a")) {MoveObject.use.Rotation(transform, Vector3.up * -120.0, .5);}
	if (Input.GetKeyDown("d")) {MoveObject.use.Rotation(transform, Vector3.up * 180.0, .5);}
}
var lastRotTime : float = 0.5;

function Update()
{
if (Input.GetKeyDown("a")  time.Time > lastRotTime + 0.5)
{
Code
lastRotTime = time.Time;
}
}

Also, check out coroutines. Your eventually going to want to put something like this in a coroutine. Easier to keep track of.

Thanks