Mechanim state triggers twice

I have a simple state machine as shown below

alt text

Idle → Kick is simply triggered when player hits the B key. I’ve set Kick → Idle with exit time 1 so that Kick gets played once and then automatically returns to the Idle state. This is the Kick → Idle properties.
alt text

The thing is, Kick plays twice for some reason. I took a close look and found that Kick played once, then it returned to Idle for like 1 frame and then again returned to Kick to play the second time and then finally returned to Idle. I don’t know if this is a bug or some mistake on my side.

This is the code to trigger Kick.

if(Input.GetKey(KeyCode.B))
{
    anim.SetTrigger("kick");
}

I changed Input.GetKey(KeyCode.B) to Input.GetKeyDown(KeyCode.B) and it worked!