python - Latency in reading from keyboard input in Pygame -


i trying measure time between event displayed on screen , until user responses input key in pygame. hope make measurement accurate possible.

what expected/worst case latency in pygame? and, alternatives read keyboard faster?

below code using right read keyboard , measure time.

def user_input(maxtime_msec):      time_start = time.time()      time_elapsed_msec = 0      key_press = false     while (time_elapsed_msec < maxtime_msec) , (not key_press):         event in pygame.event.get():             if (event.type == pygame.keydown) , (event.key == pygame.k_return):                 key_press = true             else:                 time.sleep(0.001)           time_end = time.time()         time_elapsed_msec = (time_end - time_start)*1000       return time_elapsed_msec 


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -