Looking at a common module for a rotary-encoder, there are 3 pins called "SW, DT, CLK". I learned that they are for the button when you push down on the rotary-encoder, output B, and output A, respectively. Why are they like that and not "SW, B, A". Sounds like a communication protocol pinout.
2 Answers
But in the pictures CLK is the encoder A pin and DT is the encoder B pin.
And if you consider one of the pins as clock pulse, the state of data pin on the active clock edge will tell you which way the encoder was turned.
Figure 1. The underside of the PCB reveals a little. (Image source from Amazon ad linked in OP.)

simulate this circuit – Schematic created using CircuitLab
Figure 2. Best guess at circuit.
- The three outputs are normally pulled high by 10 kΩ resistors.
- A & B will give quadrature encoded output signals which allow a controller to sense direction of rotation and angle turned.
- SW will be normally high and pull low when pressed.
Detecting direction of rotation:
- If we write the firmware to trigger on every 0 → 1 transition of the CLC pin we can then check the DT (direction of travel?) pin to sense direction.
- As shown (possibly incorrectly) in my diagram, if DT is low on the CLK 0 → 1 transition then we are going clockwise so count UP.
- If DT is high on the CLK 0 → 1 transition then we are going anti-clockwise so count DOWN.
Amazon is not a good site with respect to datasheets and my analysis makes some assumptions so you should check with a continuity tester. You can see that a simple diagram would solve any confusion.
