You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
826 B

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)