Audio Stutter

I need to play an audio when a button is held down and stop the audio when any button is not held down. Its stuttering with the following code.

function Update () {

 if(Input.anyKey ){
 
 
 if(!audio.isPlaying)
 {
 audio.Play();
 
 }
 else 
 
 {
 audio.Stop();
 
 }}}

Without the else statement the audio doesnt stutter. But i need to play audio only when the button is down.
Thanx in advance.

that Else statement has to hook up to the if(Input.anyKey) statement. It’s a lot easier to notice when you indent correctly. SO:

function Update () {
    if(Input.anyKey ){
        if(!audio.isPlaying)
        {
            audio.Play();
         }
    }
    else 
    {
        audio.Stop();
    }
}