How can i fix this animation script

The problem i have is that when i connect my code to the game object (Main character) the animation plays when i hit "d" but only plays for how long i have the button pressed and that is what i want. but when i press "a" no animation att all also how would i add the wrapmode.loop to this code any help is very appriciated

here is an example of my code `function Update () {

if (Input.GetKey(“d”)) {
animation.CrossFade(“Walk”);
}
else {
animation.CrossFade(“Idle”);
}
if (Input.GetKey(“a”)) {
animation.CrossFade(“Walk”);
}
else {
animation.CrossFade(“Idle”);
}
if (Input.GetKey(“jump”)){
animation.CrossFade (“Jump”);
}
else{
animation.CrossFade(“Idle”);
}

}`

But what i would also like is that when i hit jump i want the whole animation to play but i have tried Input.GetButtonDown but didn't work

if you can help please let me know through here or skype johnesslemont012

You are using the function GetKey. This function detects a key that is held down. You need to use Input.GetKeyDown or Input.GetKeyUp.

More info:

not sure the answer to your question, but I suggest this instead of what you have there:

function Update()
{
     var moveVector : Vector3 = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
     if(moveVector != Vector3.zero)
          animation.CrossFade("Walk");
     else
          animation.CrossFade("Idle");

     if(Input.GetButtonDown("Jump"))
          animation.CrossFade("Jump");
}

Thanks guys worked