Is there a way to change state on keypress?

I’ve used an image as a button with the action “play audio”  I’ve mapped a keystroke to the button, but would like to have it change state when I press the key.  Any help would be most appreciated!