How to rotate object x degrees on 1 key press with lerpangle

I’m a newb, so bear with me. How would I go about taking an object, and rotating it smoothly (lerpangle I assume) from its current position to another angle on one axis after a single key press.

In other words, say I have a cube, and I want to press the up arrow (and release it), and then have it smoothly transition on the x axis by -10 degrees smoothly. I hope this makes sense! I tried doing it with various lerp functions, I can get this to work:

float angle = Mathf.LerpAngle (0.0f, 30.0f, Time.time);
transform.eulerAngles = new Vector3 (0, angle, 0);

But if I put it inside
if (Input.GetKeyDown(KeyCode.RightArrow))

Then it happens instantly. Thanks!

Sorry I amm no good at c# but i can give a code to you in js and you could try and convert it.

var canturn :boolean = true;//so button spamming doesnt break it
    function Update(){
    if (Input.GetKeyDown(Keycode.RightArrow)&&canturn){
    canturn = false;
    Rotate(10,1);
    }
    if (Input.GetKeyDown(Keycode.LeftArrow)&&canturn){
    canturn = false;
    Rotate(10,-1);
    }
    
    }
    function Rotate(rot : int,mp : int)
    {
    rot = Mathf.Abs(rot);//make sure rot is positive
    for (i=0;i<rot;i++)
    {
    transform.Rotate(Vector3(0,Time.deltaTime*mp,0));
    yield;//wait 1 frame
    }
    canturn=true;
    
    }