EMT Lesson Four How to understand keys and key signatures
As an example, if a piece of music is written in the key of A major, the notes in the key will be the same as the notes in the scale, namely:
A, B, C#, D, E, F# and G#
The piece of music would look very messy if a sharp (#) symbol was written next to every C, F and G that appeared in the music. Therefore, a convention was created that instead of writing the sharps or flats next to each note in the key, they should be written at the beginning of the piece as a key signature.
If you look at Figure 2 you will see that three sharps symbols have been written on the stave at the beginning of the piece. A sharp symbol (#) has been written on the lines and spaces where the notes C, F and G would appear on the stave. This way the musician knows that each time they have to play a C, F or G, those notes will be sharpened to become C# F# and G#. It is a form of shorthand.
Figure 2. Key signature of A major

Each key, by its nature, has a specific number of flats or sharps in it and this helps musicians to easily understand, at a glance, which key they are being asked to play in.
You can use your scale knowledge to work out which notes are in each of the key.