You have to combine a myriad of different variables.
Examples of said variables include mannerisms, spouse, clothing, language use, body language, political affiliation, religious belief, everything... No ONE thing or sterortype is useful in identifying a gay person, because gay people are all different and are NOT defined by one thing or sterotype. This said, most people do follow patterns that you can observe in people. Basically you decide the probability of a given person being gay.
People with 'gaydars' basically have their mind analyze certain traits, usually automatically, and decide if someone is gay. They might not even do this consciously, but they do.
My mind works in probabilities. Based on information I get or observe on a person, I make an automatic guess about a person's sexuality. I don't actually do this consciously (...unless I like them), it just happens. Usually if I think they're straight they are, if they're gay, they are. Frequently I get conflicting messages and this is very confusing --- often in this case the person is bi....or is unusual and defies sterotypes. Because this is more of a passive thing I never actually investigate because that would be creepy and probably illegal, but the guesses that I have made and that were confirmed have all been right (partly through luck).
The most useful variable for me is are how many gay friends a person have, or what their friends are like period. Also, if a person adds me on Facebook, the pages they like and share are a huge clue.
If you're asking this so you can learn about a closeted gay: know that a gaydar is just an art of observing someone and deciding on the probability of them being gay. Even if you are good at seeing if someone is gay or not, you can not EVER say: "That person is 100% gay!" unless they confirm it in some way.
That said...
Do not rely on a 'gaydar'.
Lastly, a trick some people use (that I can't quite seem to grasp) is simply observing who a guy instinctively is checking out. Apparently if you master this, you can observe even a closeted gay men passively paying attention to men that are attractive to him.
Hopefully some of this helps. Know that a 'gaydar' is just a term for figuring out a person's sexuality based on various variables, and you will rarely be able to say: "said person is 100% gay". But, it might help you in surprising ways...
Oh, one more thing. If a person is gay friendly: Just ask them