Leveling out a Craft

I have a craft that turns (banks) left and right, and pitches up and down.

I need it to auto-level out when the user releases the key. Here is my code.

function FixedUpdate()
{
     if (Input.GetKeyUp("a"))
     {
          startRot = transform.rotation;
          ReturnRot (rotTime);
     }
}
 
function ReturnRot (time : float)
{
   var currentRot = this.transform.rotation * Quaternion.FromToRotation(transform.forward, Vector3.Scale(transform.forward, Vector3(1.0, 0.0, 1.0)));
   var originalTime = time;
 
   while (time > 0.0)
   {
      time -= Time.deltaTime;
      transform.rotation = Quaternion.Slerp (startRot, currentRot, time / originalTime);
      yield;
   }
}

I get weird snapping and just unexpected results in game.
Basically I want to Slerp from the current rotation to the identity quat preserving the Y axis component.

I would take a somewhat different route: Use the keyboard input to determine the “furthest” direction your craft banks and pitches. This is you target direction - if the user has released all keys, it is level on both axes.

Then you lerp the craft’s rotation from where it is currently towards its target. It’s the lerp that does the smoothing.

The nice thing is that you can now set your target to whatever you might want (and you can change it fast) - but your craft will turn steadily towards it. It will even turn faster from a full left → full right than it would from full left to neutral position.

I am a bit confused because I just detect if the key is pressed or not. Should I be using Input.GetAxis?