When three keys are pressed at the same time, ghosting may occur. In this example, keys A, B, and D are pressed. The matrix looks like this:
Figure 13. The A, B, and D Keys are Pressed
If everything goes well, nodes C1R1, C2R1, and C2R2 will be detected. Let's look at the circuit view again:
Figure 14. The A, B, and D Switches are Closed
When activating column C1, the circuit now looks like this:
Figure 15. Rows 1 and 2 are Activated
If you get the feeling something is not right, you are correct! This is where the ghosting problem comes to play. Row R1 is activated as well as row R2, so both nodes C1R1 and C1R2 are activated. Node C1R1 is expected as it corresponds to the A key that is pressed. However, node C1R2 corresponds to the C key. Switch C is open, so the key is not really pressed. The keyboard controller does not know this and incorrectly generates a C key press.
What happens is that closing switch B and switch D at the same time creates an electrical path from C1 to R2, bypassing the open switch C. The keyboard does not know that switch C is open and generates a "ghost" key press. Ghosting will show up when any 3 corners of a rectangle in the matrix are pressed at once. In my simple example, any 3 keys causes ghosting, but in a bigger matrix only 3 corners of a rectangle cause it.
Just for completion, here is the circuit when activating column C2:
Figure 16. Rows 1 and 2 are Activated
As expected, nodes C2R1 and C2R2 are activated corresponding to the B and D keys.