What is “anti ghosting” for a keyboard?

anti ghosting

Best Asked on March 13, 2021 in Computer.
Add Comment
  • 1 Answer(s)

    All the answers that say it means that the keyboard registers any number of simultaneous key presses are wrong. That is called “N-key rollover”.

    Anti-ghosting refers to a different thing:

    A keyboard is electrically laid out as a matrix of switches, with a specific number of rows and columns. Each key is a switch, that when pressed connects one row with one column. The actual keyboard matrix is different for different keyboard models – there’s no standard.

    “Ghosting” refers to a situation where pressing three keys that are placed in a specific pattern on the matrix makes it look like the fourth one is also being pressed.

    In this matrix, for example, pressing “C”, “F” and “B” will make it look like “H” is also pressed.

    The keyboard is read by placing a signal (usually grounding, actually) on each row in turn, and reading each column to see which keys are pressed (or the other way around, obviously). Pressing three keys as described above will cause this “signal” to leak over to the next row and make the fourth switch look like it’s being pressed.

    Which actual keys will cause this to happen on your keyboard depends on the layout of its matrix.

    The remedy for ghosting is to put a little diode in series with each switch. This will eliminate ghosting. That’s what’s called “anti-ghosting”.

    Incidentally, anti-ghosting is in fact relevant to N-key rollover, even though it’s not the same thing. Without anti-ghosting, you will not be able to trust the key presses, so there’s little point in trying to register all of them.

    Edit: One of the answers has a different explanation of ghosting that is also incorrect: The canceling out of certain pressed keys as a result of holding down two keys on the keyboard. The example given is to try typing with both shift keys held down. This is actually a different problem, caused by a combination of a lack of anti-ghosting diodes and a particular way of reading the keyboard: If the keyboard lacks anti-ghosting diodes and you strobe the rows with a “low”, you will need to leave all the other rows floating rather than high (with pullups on the column inputs, of course), otherwise they will drive other keys in the matrix high through leakage, which will cancel keypresses. This can be remedied by anti-ghosting diodes, or by changing the keyboard scanning code.

    Good Answered on March 13, 2021.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.