def key_down(self, e): command = None if e.cmd or e.key == K_ESCAPE or K_F1 <= e.key <= K_F12: command = self.command_map.get(e.key) if command: self.do_command(command) else: Screen.key_down(self, e)