def key_down(self, key, code):
        if key == pygame.K_BACKSPACE:
            self.text = self.text[0:-1]
        elif key == pygame.K_RETURN:
            can_submit = True
            if self.placeholder and self.text == self.placeholder:
                can_submit = False
            if can_submit:
                self.on_return(self, self.text)
        else:
            try:
                self.text = '%s%s' % (self.text, str(code))
            except:
                pass
            self.on_text_change(self, self.text)

        if self.max_len:
            self.text = self.text[0:self.max_len]

        self._update_text()
        self.label.shrink_wrap()
        self.label.layout()

        if self.label.frame.right > self.frame.w - self.padding[0] * 2:
            self.label.frame.right = self.frame.w - self.padding[0] * 2
        else:
            self.label.frame.left = self.padding[0]
dataset/ETHPy150Open fictorial/pygameui/pygameui/textfield.py/TextField.key_down/original