import sys import pygame pygame.init() screen = pygame.display.set_mode((640, 480)) # 设置屏幕大小 pygame.display.set_caption('mouse ctrl') # 设置窗口标题 screen.fill((0, 0, 0)) # 屏幕填充RGB颜色 while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() # 处理鼠标事件 # if event.type == pygame.MOUSEBUTTONDOWN: print("Mouse Down:", event) if event.type == pygame.MOUSEBUTTONUP: print("Mouse Up:", event) if event.type == pygame.MOUSEMOTION: print("Mouse is moving now:", event) # 处理鼠标事件 # if event.type == pygame.KEYDOWN: if event.key == pygame.K_RETURN: print("keyboard event:", event)