A light pen is a
input tool for computer systems. It is a historically rather old one and has been modified to a number of other uses (primarily game systems) through the years.
The basic workings of the light pen is a photoreceptor. This is often placed in a tube to make it easier to hold on to, thus taking the name of 'pen'. To detect where the light pen is pointing, the computer synchronizes (or is synchronized to) the video so that the gun of the Cathode Ray Tube is is at the start of its sequence - most often in the upper left hand corner of the screen. Once synchronized, the lighten detects when the scan line appears under it (as the pixel that it is looking at is drawn or being drawn) and then sends this result to the computer. The light pen driver (sometimes software, often hardware in the older systems) then is able to calculate where on the screen the light pen was from how long it took to get there after the synchronization was started.
The historic use of the light pen was more for curiosity and a few simple drawing programs that existed in the days of the Apple ][+. However, the idea of detecting where something is pointing grew into gaming systems.
The early game of 'Duck Hunt' on the Nintendo used a 'gun' known as the Light Zapper that was essentially a light pen. In the game Duck Hunt, the the targets would flash when the trigger was pulled. This flashing then was detected by the photoreceptor and indicated what target the gun was pointing at. This technique has continued to be used in modern games that involve a free gun (as opposed to those that are mounted and may detect where it is pointing through a mechanical means. As technology has progressed, the 'flicker' that was very noticeable in the Nintentdo game has bee replaced with faster and faster flashes that many times are not perceptible to the human eye.