It's a rotary encoder. It has two outputs giving pulses in quadrature (see image), as to determine the way it's rotated.
In the image you can see that the level of the B channel is low on the rising edge of the A channel if the knob is rotated clockwise, but high if rotated counterclockwise.
Differences in models are the number of pulses per rotation, often between 15 and 20, and the number of channels. More than 2 channels are used to obtain the absolute position of the knob. E.g. 10 channels give 1024 unique codes per rotation. Gray coding is used.
Another parameter is the detent. Detents are click-positions, which require a certain momentum to overcome. Some models have 2 detents per pulse, others don't have detents and rotate rather smoothly, so that it feels like a potmeter without stops.
"Control Shaft Encoders" \$-\$ Circuit Cellar issue 250, May 2011, p.28 ff