craton
craton

Reputation: 1

My pygame code won't accept input

this code wont accept input and i have no idea why its been stressing me out for days please help me if you can

while True:
 for event in pygame.event.get():
  if event.type == pygame.QUIT:
   sys.exit()
   break
  if event.type == pygame.KEYDOWN:
   for x in range (0, 29):
    if event.key == keys[b]:
     if keys[b] == pygame.K_TAB:
      now = not now
      break
      break
     if keys[b] == pygame.K_BACKSPACE:
      user = lett[b]
      break
      break
     else:
      user += lett[b]
      break
      break
  else:
   b += 1

Upvotes: 0

Views: 134

Answers (1)

paxdiablo
paxdiablo

Reputation: 881253

for event in pygame.event.get():
 if event.type == pygame.QUIT:
  sys.exit()
  break
if event.type == pygame.KEYDOWN:

It looks like your for and second if are at the same indent level.

That means you're likely to read all events in the for loop and basically throw away the ones that aren't QUIT.

This may have been a lot clearer had you stuck to the guidelines of a four-space indent - I suspect what you need to do is to indent the second if so that it's at the same indent level as the first.

Upvotes: 1

Related Questions