Oscar Johansson Oscar Johansson - 2 months ago 9
Python Question

Is there a way with pygame to get keyboard input when the window is minimized?

Title says it all. Is there a way with pygame to get keyboard input when the window is minimized?

Thanks.

Answer

Yes, although you have to have it focused.

import pygame
pygame.init()

pygame.display.iconify()

while 1:
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            print(event.key)

Otherwise it seems to not be possible according to this answer and this answer