How do I create a light source in OpenGl?

i.e. I want to put a light in my room design which lights on when I press a key.How can I get that effect?

Try playing around with EMMISION material property.
You could create a quadratic sphere with normal properties which uses EMMISION when you press the key.