rotate 2d object for a period of time on a keypress

I am a super novice who very slowly is making a project. Sorry for my ignorance ahead of time. What I want to do is rotate a 2D object in 3D space for a specific amount of time on a key press. I can rotate on a keypress but I dont know how to add a time element. An example would be that I want the 2D object to rotate for 3 seconds on a keypress. Below is the basic rotate script I have so far.

public class Rotator : MonoBehaviour {
	

	void FixedUpdate () 
	{	
		if (Input.anyKey)

			transform.Rotate (new Vector3 (0, -90, 0) * Time.fixedDeltaTime);
	}
}

I dont even know if I am thinking about this the right way. Should I be trying to set up a rotate target like 180 degrees that is completed over a period of time? Thanks.

@mr_dna Try this.

	public float maxTimer = 0.5f;
	void Start () {
	
	}
	void Update () {
	
		if(Input.anyKeyDown)
		{
			StartCoroutine(RotateObject());
		}
	}
	IEnumerator RotateObject()
	{
		float timer = 0f;
		while(timer <= maxTimer)
		{
			transform.Rotate (new Vector3 (0, 60, 0) * Time.deltaTime);
			timer +=Time.deltaTime;
			yield return null;
		}
	}

Here you go:

using UnityEngine;
using System.Collections;

public class rot : MonoBehaviour {
	
	
	public GameObject OurObject; // the object you want to rotate. 
	
	public float RotationTime = 3f; // In seconds
	
	public float RotationSpeed = 0.5f; // round per second
	float timeLeft; 
	
	
	void  Update() {
		
		timeLeft -= Time.deltaTime;
		
		if (Input.GetKey("r") && timeLeft < 0){
			
			timeLeft = RotationTime;
			
		}
		
		if (timeLeft > 0){
			
			OurObject.transform.Rotate(0,0, Time.deltaTime * RotationSpeed * 360 );
			
		}
		
	}
}

What setting are you using?