It has been long time since I used OpenGL, but I'll try to help.
First, if you know how to intilialize OpenGL properly try the following approach.. otherwise wait for someone else to help:p
Second, I didn't test the code and I'm not sure whether it works or not.
Add the following global variables (you can change the values as you like) :
int lineHight = 25; // the hight of each line
int lineMargin = 10; // the left margin for your text
int currentHight = 25; // the y position of the cursor.
Now in the main function and after OpenGL initialization enter the following lines:
glutKeyboardFunc(myKey); // register the key handler.
glRasterPos2f(lineMargin, currentHight); // set the cursor to the initial position.
And here is some definition of the key handler:
void myKey(unsigned char key, int x, int y)
if (key == 13) // enter key
currentHight += lineHight; // change cursor y position
glRasterPos2f(lineMargin, currentHight); // jumb to next line
glColor3f(0.0, 0.0, 1.0); // text color
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, key); // print the color