You say, "Sure," and launch into "Red-Haired Boy."
No one else joins in, so you stop. The person next to you says, "That's an 'A' tune. We're in 'D.' "
You name a couple of other tunes, which also get the response, "Wrong key." Mercifully, someone else picks a tune.
So you've learned some tunes by ear, and can play them from memory, but you forgot to memorize what keys they were in. How can you figure it out?
In the absence of sheet music, one can discern the key signature of a melody by examining the notes it contains. Absent accidentals, if the melody contains, for example, a G#, C#, and F#, but the remaining notes of the scale have neither sharps nor flats, the key is 'A,' If, in contrast, there are F# notes, but the C and F are natural, then the key is 'G,' unless the tune is in the relative minor of that key, 'Em,' in which case zzzzzz...Oh. Sorry. I fell asleep while I was talking.
(It's said that Nobel Laureate, Thomas Hunt Morgan, yawned on walking into his lab, then said, "You'll have to excuse me. I just came from one of my own lectures.")
When you have sheet music handy, counting the number of sharps in the key signature will help you figure out the key of the tune. When you don't, or that seems like too much work, just play the last note.
That's the key.
Odds are, each part ends on the same note; however, if the parts end on different notes, pick the one at the very end of the tune. Tunes often even start on the note that names their key, but that's less reliable.
Whether your tune's major, minor, or modal, this trick just works. Sure there are exceptions, because there are exceptions to everything. In this case, they're rare.
As they say in infomercials, "What would you pay? But wait! There's more." Most fiddle tunes are in D, A, or G, and it's no coincidence that these are the bottom three strings of the fiddle or mandolin. You can often rephrase the key question as "Which open string does my tune end on?" (The tune may end on, say, a high G instead of a low G, but it's still a first-rate clue.)
If you spent too much time in marching band as a kid, and you still have a nagging feeling that only sheet music can really tell you the key, ask yourself what you'd say if the sheet music had one sharp. G major? Absolutely. E minor? Okay, maybe that, instead. D myxolidian? A dorian? Not in Sousa marches, but both are as common as pins in American traditional music.
The final note is a more sure-fire way to determine the key than the key signature. Why didn't your clarinet teacher ever tell you that? Don't ask me, ask your clarinet teacher.
Now go figure out which tunes you play are 'D' tunes.