Identifying Key Signatures
Each key signature is related to a major scale and its relative minor. With practice, it is possible to memorize the accidentals that are typical of each scale. Meanwhile, key signatures may be identified and built otherwise.
Identifying Key Signatures of Sharps:
The major scale to which it belongs is a half-step above the last sharp:
Identifying Key Signatures of Flats:
The major scale to which it belongs is a perfect fourth below the last flat. In case of more than one flat, tonality is also indicated by the penultimate flat:

