Use inkey to do this. To display the text, you need a text object. Look these up in the manual. If the health bar moves around on the screen, you can set the position of the text object to be relative to the health bar like this:
player_name.pos_x = healthbar.pos_x; // same X position
player_name.pos_y = healthbar.pos_y + 96; // 96 pixels below the health bar - adjust as needed