The key signature is something that is in music showing what black key(or sometimes white key, for example, E# or Cb) you need to play and that is sharps or flats .It is listed after the Clef. This is to avoid the repetition of accidentals in the score. They are listed on every line of music, which signifies what key the composer has chosen.
There is a key signature for each scale in minor and major scale. There are in total of seven flats and sharps, the flat looks like a "b" and the sharp looks like a "#". There are seven sharps~... F sharp, C sharp, G sharp, D sharp, A sharp, E sharp and B sharp and seven flats~...B flat, E flat, A flat, D flat, G flat, C flat and F flat, that is the order that they are placed on a music sheet on both treble and bass clef. There are two scales that don't have sharps or flats and those are C major and A minor. You can add sharps and flats during the piece that are not already placed at the beginning of the piece.
In order to remove the flat or sharp you need to add a natural, that removes the sharp of flat for one bar and you can add it any where to block or cancel the sharp or flat.
List of key signatures edit
Here is a complete list of key signatures: