Western music is usually tonal. In other words it is in a key. There are two types of key, major keys and minor keys.
A piece of music made from the notes of a scale is said to be in the key of that scale. The key signature tells us which notes are in a particular scale or key. The simplest key to understand is C major which has no sharps or flats. It contains only the white notes on the piano: A, B, C, D, E, F and G.
G major has an F# in the key signature so the notes in the key of G major are A, B, C, D, E, F# and G.
The starting note of a scale is also know as the key note or the tonic of the key.
There are 12 different notes but there are 15 major keys and 15 minor keys. How come?
Well, 3 of the keys can be written with either sharps or flats. So the key based on the note F# can be written as the key of F# major (with 6 sharps in the key signature) or it can be written as the key of Gb major (with 6 flats in the key signature). It is quite a difficult topic to understand until you have studied music theory in depth!
There can be up to seven sharps or seven flats in the key signature. This chart shows all of the possible key signatures and keys:
Click here to download and print this key signature chart.