def _next_keys(self, key_press):
        """Handles the magic typing when a key is pressed"""

        if key_press.key in {Keys.Escape, Keys.ControlC}:
            echo(carriage_return=True)
            raise Abort()

        if key_press.key == Keys.Backspace:
            self.current_command_pos = max(0, self.current_command_pos - 1)
            return [key_press]

        if key_press.key == Keys.CPRResponse:
            return []

        if self.current_command_pos < len(self.current_command()):
            current_keys = self.current_command_keys()
            self.advance()
            return [KeyPress(k) for k in current_keys]

        # Command is finished, wait for Enter
        if key_press.key != Keys.Enter:
            return []

        self.current_command_index += 1
        self.current_command_pos = 0
        return [key_press]
Handles the magic typing when a key is pressed
src/doitlive/ipython/app.py