title: Pygame mouse hold
body: <p>I am designing an incremental/clicker game in pygame, and I want to change the $ counter by 1 every click. However, I can hold the button down, and I can't find a way to limit this. </p>
  
  <p>My button class is below:</p>
  
  <pre><code>class Button(object):
      def __init__(self,x,y,width,height,color):
          self.rect=(x,y,width,height)
          self.image=pygame.draw.rect(screen, color,(self.rect),)
          self.x=x
          self.y=y
          self.width=width
          self.height=height
      def check(self):
          mouse=pygame.mouse.get_pos()
          if self.x+self.width &gt;mouse[0] &gt; self.x and self.y+self.height &gt;mouse[1] &gt; self.y:   
              if pygame.mouse.get_pressed()[0]==True:
                  return True
  </code></pre>
  
  <p>Is there a way to stop the button from being held down?</p>
  
  <p>All help is appreciated!</p>
  
  <p>Full code:</p>
  
  <pre><code>import pygame, sys
  from pygame.locals import *
  
  pygame.init()
  
  light_gray=(211,211,211)
  black=(0,0,0)
  white=(255,255,255)
  
  def terminate():
      pygame.quit()
      sys.exit()
  
  def drawText(text, font, screen, x, y,color):
      textobj = font.render(text,True, color)
      textrect = textobj.get_rect(center=(x,y))
      screen.blit(textobj, textrect)
  
  class Button(object):
      def __init__(self,x,y,width,height,color):
          self.rect=(x,y,width,height)
          self.image=pygame.draw.rect(screen, color,(self.rect),)
          self.x=x
          self.y=y
          self.width=width
          self.height=height
      def check(self):
          mouse=pygame.mouse.get_pos()
          if self.x+self.width &gt;mouse[0] &gt; self.x and self.y+self.height &gt;mouse[1] &gt; self.y:   
              if pygame.mouse.get_pressed()[0]==True:
                  return True
  
  clock=pygame.time.Clock()
  
  font=pygame.font.SysFont(None,50)
  
  screen_width=1300
  screen_height=700
  screen=pygame.display.set_mode([screen_width,screen_height])
  
  pygame.display.set_caption('Clicker')
  
  done=False
  
  money=0
  
  sprites=pygame.sprite.Group()
  
  button=Button(25,screen_height-125,500,100,light_gray)
  
  while not done:
      for event in pygame.event.get():
              if event.type==QUIT:
                  terminate()
  
      if button.check()==True:
          money+=1
  
      screen.fill(light_gray)
  
      sprites.draw(screen)
  
      pygame.draw.rect(screen,black,button.rect, 3)
      text_width, text_height=font.size('Click!')
      drawText('Click!', font,screen,button.x+button.width/2,button.y+button.height/2,black)  
  
      drawText('$'+str(money),font,screen,screen_width/2,25,black)  
  
      pygame.display.flip()
  
      clock.tick(15)
  
  pygame.quit()
  </code></pre>