简体   繁体   中英

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
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM