I'm working on a project and I found this code for a text box in Python: How to create a text input box with pygame?
Now, I want to change the code so that while the user holds backspace the text box will delete characters.
I tried to change the code to this:
if event.type == pg.KEYDOWN:
    if self.active:
        if event.key == pg.K_RETURN:
            self.text = ''
        if event.key == pg.K_BACKSPACE:
            while pg.KEYDOWN is pg.K_BACKSPACE:
                print "shock"
                self.text = self.text[:-1]
        else:
            self.text += event.unicode
        # Re-render the text.
        self.txt_surface = FONT.render(self.text, True, self.color)
but it does not work and I can't find any solutions online.
 
     
    