Why are the pygame arrow values not the same as the ascii values?

Viewed 73

I'm using the pygame library and I went to print out the value as follows:

print(pygame.K_UP)

and I got 1073741906 as the value. What's the explanation?

pygame.K_a

is 97 as expected. It's also possible that this is simply a Python thing and not pygame specific.

1 Answers

See the documentation of the pygame.key module:

Portability note: The integers for key constants differ between pygame 1 and 2. Always use key constants (K_a) rather than integers directly (97) so that your key handling code works well on both pygame 1 and pygame 2.

Related