import pygame from pygame.locals import * import sys pygame.init() display = pygame.display.set_mode((500,500)) FPS_CLOCK = pygame.time.Clock() Visible = 1 while 1: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_a: if Visible == 1 : pygame.mouse.set_visible(False) Visible = 0 print("Mouse is not visible") elif Visible == 0 : pygame.mouse.set_visible(True) Visible = 1 print("Mouse is visible") pygame.display.update() FPS_CLOCK.tick(30)