pygame
pygame copied to clipboard
get_just_pressed() and get_just_released() functions
Response to changes requested in #3190 (unfortunately had to open another PR because I now longer have the repo I made those changes in). As requested in #3175 there should be more global access to key information which can be accessed without going via the event loop. Here is an example of the api usage:
if pygame.key.get_just_pressed()[pygame.K_b]:
print("B Pressed")
if pygame.key.get_just_pressed()[pygame.K_a]:
print("A Pressed")
if pygame.key.get_just_released()[pygame.K_b]:
print("B Released")
if pygame.key.get_just_released()[pygame.K_a]:
print("A Released")
This is a very impressive pull request for a first time contributor!
Left a couple notes from a quick skim.
It would be good for you to do a setup.py format and add type stubs to get a couple more of the test runners passing.
Type stubs are here: https://github.com/pygame/pygame/tree/main/buildconfig/stubs/pygame
It also needs unit tests, those would go in here: https://github.com/pygame/pygame/blob/main/test/key_test.py
lol, I accidentally closed this