What i would do is create a boolean to define wheter the button was pressed or not
Here is an example:
self.pressed = False
if key[pygame.K_z]:
self.pressed = True
if self.pressed:
robsHouse.printText(screen)
then at then when you want the text to go away set self.pressed
to False
and it will stop being blitted
like this:
def printText(self, surface):
if self.counter < 20:
text = pygame.font.SysFont("Pixelated Regular", 30)
label = text.render("Hello", 0, (0,0,0,))
surface.blit(label, (100,100))
self.counter += 1
else:
self.pressed = False
That way once the counter ends the text will dissapear
Hope that helps!