fun() self.cv.bind("<KeyPress-%s>" % key, eventfun) screen = Screen() screen.setup(width=600, height=600) screen.title("Speed Typing Test") screen.tracer(0) screen.listen() typewriter = Typewriter() prompt = Prompt() screen._onkeypress = partial(_onkeypress, screen) screen.onkeypress(typewriter.record_keypress) countdown_timer = CountdownTimer(5) speed_test_on = True while speed_test_on: screen.update() # Update countdown timer countdown_timer.increment_time() # Detect whether timer elapsed if countdown_timer.timer_over: prompt.clear_prompt() typewriter.game_over()