Skip to content

Instantly share code, notes, and snippets.

@stamaniorec
Created October 31, 2015 11:51
Show Gist options
  • Select an option

  • Save stamaniorec/12f1e3dc48bd8da5bbfa to your computer and use it in GitHub Desktop.

Select an option

Save stamaniorec/12f1e3dc48bd8da5bbfa to your computer and use it in GitHub Desktop.
#pygame mouse event handling
while is_running:
for event in pygame.event.get():
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
print("Left button")
elif event.button == 3:
print("Right button")
# 4, 5, 6 are scroll events, not sure about the details
elif event.type == MOUSEBUTTONUP:
if event.button == 1:
print("Released left button")
elif event.button == 3:
print("Released right button")
else:
pass # scroll events
elif event.type == pygame.MOUSEMOTION:
mouse_x = event.pos[0]
mouse_y = event.pos[1]
print("%s %s" % (mouse_x, mouse_y))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment