The code is meant to quickly exit pygame by tapping escape.
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN():
if event.key == pygame.K_ESCAPE:
running = False
pygame.quit()
sys.exit()
This code errors with this:
Message File Name Line Position
Traceback
<module> G:\Code\JonSocket\keyboard.py 19
TypeError: 'int' object is not callable
Very similar code works when,
event.type == pygame.QUIT
Is there a difference between pygame.QUIT + pygame.KEYDOWN?
Thanks.
Your problem is in the line
if event.type == pygame.KEYDOWN():
pygame.KEYDOWN
is not a function but just an integer constant.
Change it to
if event.type == pygame.KEYDOWN:
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.