title: Button Functions running until mouse unclicked
body: <p>I've made a few buttons, although when I click down on the buttons to run the function, the button runs repeatedly until I release the click. Is there a way to get the function to run once per click down rather then until it is released. Here it the button function:</p>
  
  <pre><code>def Button(msg, x, y, w, h, ic, ac, action=None):
      mouse = pygame.mouse.get_pos()
      click = pygame.mouse.get_pressed()
      if x+w &gt; mouse[0] &gt; x and y+h &gt; mouse[1] &gt; y:
          pygame.draw.rect(window, ac, (x, y, w, h))
          if click[0] == 1 and action != None:
              pygame.draw.rect(window, lightgrey, (x, y, w, h))
              if action == "undo":
                  print("hey")
  </code></pre>
  
  <p>Printing hey is to test when undo is clicked. But depending on how slightly the button is pressed it prints at least hey 5 times as I cannot release the click down fast enough.</p>