Character Animation Assistance

hey guys… I’m looking for some help with my character animation script so far it is:

#pragma strict


function Start () {

}

function Update()
{
   if (Input.GetAxis("Vertical") > 0.2) 
       animation.CrossFade ("walk");
   	else if (Input.GetAxis("Vertical") < 0.2) 
      animation.CrossFade ("idle");


 if (Input.GetKeyDown ("space"))

   animation.Play ("jump");

else if (Input.GetKeyUp ("space"))

   animation.CrossFade ("idle", 1);

else if(Input.GetAxis("Vertical") < -0.2){

       animation.CrossFade ("walk", - 0.05);

   } 
   
  
}   

I apologize for the disorganization of my script but i need help with getting the player to complete the attack function on key “f”. whenever i press it it plays for a brief second and then switches to idle. is there someway he will play the animation then switch to idle? please guys i need some help!

Instead of :

else if (Input.GetKeyUp ("space"))

try using :

else if (Input.GetKeyUp ("space") && animation.isPlaying("jump") == false)