How can I make an object rotate to one point and not keep looping?

I have an object with this function:

if(Input.GetKey(KeyCode.Mouse0)){

			transform.Rotate (0,0,900*Time.deltaTime);
		}

My object just keeps rotating forever , when my objective is to , when the user touches/mouse the object rotates and changes the side its pointing by 180 degrees , and then back to 0.
How can I make it stop rotating?

I’m not sure how you expect that to happen, considering what you are doing is rotating the object at 900 degrees per second while the mouse/touch is down.

My best suggestion is to make a coroutine to do the rotating, activate it on GetKeyDown(only when it’s pressed, not while it’s being pressed) and use a flag to avoid activating it while it’s still running.