Animation while waiting for keyboard input
I was wondering what the best way would be to show an animation (a shrinking rectangle indicating how much time a person has left to answer a question) while waiting for a key response of the participant?
My current approach would be something like this (pseudocode):
while time < allowed_time and key is None:
key, time = my_keyboard.get_key(keylist = ..., timeout = 20) #very small timeout so that the animation can update smoothly
my_canvas.rect(....) #update rectangle to slightly smaller rectangle
But I'm worried that my animation will not work smoothly or that the key response will not be recorded correctly.
Does anybody have a better idea?