The keyboard matrix is the arrangement of circuit connections between the keyboard controller and all the keys on the keyboard. Each key does not have its own dedicated circuit; instead, each key is placed at the intersection of a matrix row and a matrix column. The keyboard repeatedly applies current to each column in turn, and checks to see which rows output current. From this, the keyboard can deduce which keys in that column have been depressed. The matrix takes the form of a wired array, either on a conventional PCB, on a hand-wired cable grid, or on membrane sheets.
The matrix arrangement allows for current to flow backwards through part of the circuit, which leads to "ghost" keypresses being detected when certain groups of three keys are held down. This "ghosting" can be prevented by placing diodes in series with each switch (before or after) or by using capacitive sensing. The problem can be mitigated by using a gaming-optimised matrix or by blocking any combination of three keys or more, forcing 2KRO. The latter prevents keyboard shortcuts from functioning, in addition to being difficult to game on. So the matrix might be laid out in such a way as to ensure that pressing groups of three or four keys works so long as all but one of the keys are modifiers. Keyboard shortcuts involving multiple modifiers is a relatively modern phenomenon on PCs, so vintage keyboards without diode protection will either ghost or block certain shortcuts.
As a result of this and the fact that keys on the keyboard are not all square, the matrix arrangement does not take the form of a regular grid. Adjacent matrix intersections do not always correspond with adjacent keys and vice-versa.