Since your code contains an elif statement and no if statement, I have to assume that some key information is missing.
When does the routine end?
One approach would be to wait until the end of the routine and then cycle through all of the keyboard responses checking to see if each one is in the window and setting a flag to True if it is. Then save data based on whether the flag is True or False.
Does the routine only contain one window? I’m wondering whether your 0-4 is for overshoots because you think that y with go back to zero. Shouldn’t it be 54 to 64 seconds (or possibly 56 to 64 seconds if you want 4 seconds either way).
You might find my PM Time demo task useful to look at if you are also wanting participants to be able to check the time.