Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pygame catching Enter Button

I am trying to catch Enter button with pygame, not Enter button on keypad, which I want is the Enter button under Backspace button. They are not same, because when I catch Enter button on keypad, other Enter button is not working.

http://www.pygame.org/docs/ref/key.html

There is a documentation about keys, but there is only keypad Enter button. I tried these codes:

This working for keypad Enter button, but other Enter button is not working:

if event.type==pygame.KEYDOWN:
    if event.key==pygame.K_KP_ENTER:
        #some codes

I tried to catch another Enter button with these codes(hopeless):

if event.type==pygame.KEYDOWN:
    if event.key==pygame.K_ENTER:
        #some codes

But of course an error appears:

AttributeError: 'module' object has no attribute 'K_ENTER'

Couldn't figure out how to catch Enter button under Backspace.

like image 806
GLHF Avatar asked Dec 27 '14 06:12

GLHF


1 Answers

I think you want K_RETURN , as the enter key under the backspace is sometimes referred to as "carriage return", from old typewriter lingo.

like image 65
levis501 Avatar answered Oct 03 '22 09:10

levis501