The tap code, sometimes called the knock code, is a way to encode text messages on a letter-by-letter basis in a very simple way. The message is transmitted using a series of tap sounds, hence its name.
The tap code has been commonly used by prisoners to communicate with each other. The method of communicating is usually by tapping either the metal bars, pipes or the walls inside a cell.
The tap code is based on a Polybius square using a 5×5 grid of letters representing all the letters of the Latin alphabet, except for K, which is represented by C.
The listener only needs to discriminate the timing of the taps to isolate letters.
Each letter is communicated by tapping two numbers
For example, to specify the letter "B", one taps once, pauses, and then taps twice.
Or to communicate the word "water", the cipher would be the following (the pause between each number in a pair is smaller than the pause between letters):
The letter "X" is used to break up sentences, and "K" for acknowledgements.
Because of the difficulty and length of time required for specifying a single letter, prisoners often devise abbreviations and acronyms for common items or phrases, such as "GN" for Good night, or "GBU" for God bless you.
By comparison, Morse code is harder to send by tapping or banging because it requires the ability to create two differently sounding taps (representing the dits and dahs of Morse code). A Morse code novice would also need to keep a "cheat sheet" until he or she remembers every letter's code, which the captors would likely confiscate. Tap code can be more easily decoded in one's head by mentally using the table. For example, if you hear four knocks, you would think A… F… L… Q as the count increased; then after the pause, you hear three knocks and think Q… R… to arrive at the letter "S".
The origins of this encoding go back to the Polybius square of Ancient Greece. As the "knock code", a Cyrillic script version is said to have been used by nihilist prisoners of the Russian czars. The knock code is featured in Arthur Koestler's classic 1941 work Darkness at Noon.