How to add a text object?
you can edit written text via string game property but you need to assign it to your drawing property in this method, here is the code.

# import game engine modules
from bge import render, logic
# import stand alone modules
import bgl, blf

# create a new font object, use external ttf file
font_path = logic.expandPath('//C://Documents and Settings//Guillermo//Mis 
documentos//Google Drive//Gproyectos//Proyectos con Blender//Zeyada.ttf')
# store the font indice - to use later
font_id = blf.load(font_path)
# we get the game property and assign it before drawing so we can change it always 
cont = logic.getCurrentController()
chain = cont.owner['msg']

def write():
    """write on screen"""
    width = render.getWindowWidth()
    height = render.getWindowHeight()
    # OpenGL setup
    bgl.glMatrixMode(bgl.GL_PROJECTION)
    bgl.glLoadIdentity()
    bgl.gluOrtho2D(0, width, 0, height)
    bgl.glMatrixMode(bgl.GL_MODELVIEW)
    bgl.glLoadIdentity()

    # BLF drawing routine
    blf.position(font_id, (width * 0.2), (height * 0.3), 0)
    blf.size(font_id, 50, 72)
    bgl.glColor4f(1.0, 0.0, 0.0, 1.0)
    blf.draw(font_id,chain)

# set the font drawing routine to run every frame
scene = logic.getCurrentScene()
scene.post_draw = [write]


all you have to do is changing the owner property "msg" it will be drawn, you can also put a keyboard sensor and set the "msg" string as keystrokes log property so it will receive the keystrokes and display, them you don't need to connect it to the python controller but make sure that the code is always running, the code should be with the object that has the property "msg".