Answers for "pygame left mouse click"

5

pygame get mouse position

x,y = pygame.mouse.get_pos()
#get the mouse cursor position
#get_pos() -> (x, y)
#Returns the X and Y position of the mouse cursor.
#The position is relative to the top-left corner of the display.
#The cursor position can be located outside of the display window,
#but is always constrained to the screen.
Posted by: Guest on May-20-2020
1

rightclick in pygame

if event.type == pygame.MOUSEBUTTONDOWN:
    print(event.button)
    
#------------------------#
1 - left click
2 - middle click
3 - right click
4 - scroll up
5 - scroll down
#------------------------#
Posted by: Guest on July-28-2021
0

pygame left click

if event.type == pygame.MOUSEBUTTONDOWN:
  if event.button == 1:
    print("Left Mouse Button Down!")
Posted by: Guest on April-13-2021
0

pygame right mouse button

if event.type == pygame.MOUSEBUTTONDOWN:
    print(event.button)
Posted by: Guest on September-11-2021

Python Answers by Framework

Browse Popular Code Answers by Language