I'm not familiar with this because it's English even though I googled How do I get a full screen when I press a certain key in a pie game?
python
You can change to full screen by invoking the following command:
pygame.display.set_mode(screensize, FULLSCREEN)
The entire code that applied it.
import pygame
from pygame.locals import *
import ctypes #To obtain resolution
surface = pygame.display.set_mode((500, 500))
while True:
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == order('f'): When you press #f
user32 = ctypes.windll.user32
screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1) #Discover the resolution
surface = pygame.display.set_mode(screensize, FULLSCREEN) # Switch to full screen
pygame.display.update()
surface.fill((255, 255, 255))
I hope it was helpful!
Insert the event code and switch to full screen when the event occurs.
Please refer to the link below.
https://www.pygame.org/wiki/toggle_fullscreen?parent=CookBook
© 2025 OneMinuteCode. All rights reserved.