0

I'm just starting out and learning Python/PyGame. I'm currently following a tutorial but have run into the following error whenever a key is pressed:

File "wormy.py", line 134, in checkForKeyPress
  return keyUpEvents[0].keyUpEvents
AttributeError: event member not defined

The actual code in question is:

def checkForKeyPress():
    if len(pygame.event.get(QUIT)) > 0:
        terminate()

keyUpEvents = pygame.event.get(KEYUP)
    if len(keyUpEvents) == 0:
        return None

if keyUpEvents[0].key == K_ESCAPE:
    terminate()

return keyUpEvents[0].keyUpEvents

Could someone explain what I'm doing wrong here please?

2
  • Does this similar question helps you? stackoverflow.com/questions/34575274/… Commented Apr 3, 2017 at 11:17
  • @afsharm Unfortunately, the similar question isn't really much help. I am rather new to python.pygame and this code snippet is an exact copy of a tutorial I was following so I'm unsure where it's gone wrong. Commented Apr 4, 2017 at 13:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.