The Hanky Code was a traditional form of signaling to others your sexual preferences, fetishes and interests were.
Gay men used this code to communicate with each other in the noisy and distracting environment of gay bars.
According to J. Raúl Cornier for The History Project Boston,
The hanky code was a covert sartorial code used predominately by queer men in the 1970s and into the 1980s. Simply put, a bandana is worn in one’s back pocket for the purposes of sexual signaling. The color of the bandana was associated with a specific sexual practice or fetish, and the wearer’s sexual role was indicated by which back pocket the bandana resided in (tops wore bandanas in their left pocket; bottoms wore bandanas in their right pocket).
The hanky code initially began with the use of red bandanas to discreetly identify practitioners of fisting. A decoder list was created as other color/fetish associations were added. (In many early hanky codes, red typically appears as the first color.) Queer businesses printed the hanky code decoder lists for distribution. Erotica shops, bookstores, and catalogs provided decoder lists with the purchase of bandanas, while gay bars printed the lists with location information as a form of marketing.