Some other useful methods to work with events are the
set_blocked()takes in a pygame event or a list of events that you want to be blocked from the queue. If you use
Noneas the input, all events will be blocked from the queue.
set_allowed()does the opposite of the previous method. It takes in a pygame event or a list of events that you would like allowed in the queue. If you input
None, all events will be allowed.
get_blocked()will return a boolean based on whether or not an event is blocked from the queue. If a list of events is passed in, the method will return
Trueif one of the events is blocked.
# blocks QUIT and KEYUP from the queue pygame.event.set_blocked(pygame.QUIT) pygame.event.set_blocked(pygame.KEYUP) # allows QUIT to the queue pygame.event.set_allowed(pygame.QUIT) print(pygame.event.get_blocked(pygame.QUIT)) # prints False print(pygame.event.get_blocked(pygame.KEYUP)) # prints True