Sometimes, especially when doing an eye exam on small children the eye doctor will direct a light in the eyes. But why? Such as test is used to help test the refractive error of your eye, and it's known as retinoscopy. By examining the reflection of light off your retina, your optometrist can assess if you are nearsighted, farsighted or have astigmatism, and can also get a pretty good reading on the prescription you would need to correct your vision.
Basically, what we are doing during a retinoscopy exam is checking how well your eye can focus. When light shines into your eye using a retinoscope, a reddish light reflects off your retina, through your pupil. We call this the red reflex. This process measures your focal length, or in layman's terms, it will measure the precise angle of refraction of light off your retina which tells us how well your eye focuses. If it's apparent that you can't focus well, we hold several lenses with varying prescriptions in front of the eye to see which one rectifies your vision. The lens power that works is the prescription you will need to fix your impairment with glasses or contact lenses.
The eye doctor will run your exam in a dark room. You will usually be instructed to look at something ahead, just behind the doctor. This makes eyes easier to examine. Not having to read any eye charts means that a retinoscopy exam is also a very useful tool to determine the prescriptions of those who may struggle with speech, like young children and the elderly.