Okay in the start of what ever class you want to put the code in you should declare a variable:
public GreenfootSound sound = new GreenfootSound("filename.format");
And then after your if( Greenfoot.isKeyDown("a") ) you should use:
if (!sound.isPlaying()) //checks that the sound isn't already playing
{
sound.play(); //plays the sound
}