02fentym
02fentym

Reputation: 1772

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

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.

Upvotes: 2

Views: 129

Answers (1)

Rabbid76
Rabbid76

Reputation: 210889

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.

Upvotes: 1

Related Questions