while True:
clock.tick(1)
for event in pygame.event.get():
print(event, time.ctime(time.time()))
设置帧率为1后
尽管在1秒内快速按下两个键,event都被捕捉,但是捕捉到的event仍存在数秒误差间隔这是为什么?(包括keydown和keyup,以及两个a的输入都存在数秒)
'''
<Event(768-KeyDown {'unicode': 'a', 'key': 97, 'mod': 4096, 'scancode': 4, 'window': None})> Wed Sep 8 00:43:49 2021
<Event(770-TextEditing {'text': 'a', 'start': 1, 'length': 0, 'window': None})> Wed Sep 8 00:43:49 2021
<Event(769-KeyUp {'unicode': 'a', 'key': 97, 'mod': 4096, 'scancode': 4, 'window': None})> Wed Sep 8 00:43:52 2021
<Event(770-TextEditing {'text': 'a', 'start': 1, 'length': 0, 'window': None})> Wed Sep 8 00:43:54 2021
<Event(768-KeyDown {'unicode': 'a', 'key': 97, 'mod': 4096, 'scancode': 4, 'window': None})> Wed Sep 8 00:43:54 2021
<Event(770-TextEditing {'text': "a'a", 'start': 3, 'length': 0, 'window': None})> Wed Sep 8 00:43:54 2021
<Event(769-KeyUp {'unicode': 'a', 'key': 97, 'mod': 4096, 'scancode': 4, 'window': None})> Wed Sep 8 00:43:56 2021
'''