0

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

Thanks.

Oscar Johansson
  • 135
  • 1
  • 2
  • 11

1 Answers1

1

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

Community
  • 1
  • 1
Ted Klein Bergman
  • 9,146
  • 4
  • 29
  • 50