Open the door slowly, pressing a key on the keyboard

Hi , I use this script below to open a door using only code, the script works very well.
I would like the door opened slowly, and also pressing the “A” key on your keyboard.
Could anyone help me with details if possible , because I do not know JavaScript very well . thank you

var close = false;
var doorCode : String = "";
var stringToEdit : String;
var buttonMessage : String = "type code";

function SetTheGUI () {
    close = true;
}

function UnSetGUI () {
    close = false;
}

function OnGUI(){
if (close){
   stringToEdit = GUI.TextField (Rect (500, 300, 120, 25), stringToEdit, 10);
    
   if(stringToEdit == doorCode){
      buttonMessage = "open Door";
   }else{
      buttonMessage = "type code";
   }
   
   if(GUI.Button(Rect(500, 265	, 120, 25), buttonMessage) && stringToEdit == doorCode){
   		
   		transform.Rotate(-90,0,0);

   }
    
}
}

You should use an animation to do that, to have a perfect control over it. To make that animation, look over here. To play the animation, it’s over there.

But if you really want to use the Rotate function, first thing is, don’t do it in OnGUI : that function is called twice per frame. Enable a boolean, then in update do something like that :

if( openDoor && transform.rotation.eulerAngles.x > -90 )
    transform.Rotate(-Time.deltaTime * rotSpeed,0,0);

Note that it’s probably y you want to animate.