When you have sheet music, there's a technique for deriving it from the pile of sharps or flats at the top.
If there's sharps in the key signature, what you do is find the last sharp and the note one half step above that sharp note is the key. For example,
One half step above C# is D. So D Major.
One half step above B# is C, which, in this key, already has a sharp, so C# Major it is.
Most people just memorize them.
For flats, it's a little different. You can find the second to last flat, and that's the major key signature. Flats are easy!
The second to last flat is on G, so Gb Major.
This trick works for all of them except, of course, F Major, which has one flat:
Just remember that one flat is F Major.
For minor key signatures, you can count up six scale degrees on the major key signature, or count down three half steps. I usually count down, because for me that's easier, but it's technically more correct to view the minor key signature as starting on the sixth scale degree. Anyway, if you figure out the major key signature, you can figure out the minor key signature.