def on_keystroke(self, callback, *args):

    def on_keystroke_handler(key):
        self.awaiting_keystroke = False
        self.terminal_controller.remove_any_key_handler()
        callback(*(args + (key,)))
    self.terminal_controller.add_any_key_handler(on_keystroke_handler)
    self.awaiting_keystroke = True
def on_keystroke(self, callback, *args):

    def on_keystroke_handler(key):
        self.awaiting_keystroke = False
        self.terminal_controller.remove_any_key_handler()
        callback(*(args + (key,)))
    self.terminal_controller.add_any_key_handler(on_keystroke_handler)
    self.awaiting_keystroke = True