Question on button action script

I’m making a movie that makes a baseball cap rotate as long as a button is pressed. How can I do this?