A key signature is a collection of sharps (#) or flats (b) shown at the beginning of a staff. It indicates the tonal center or key of a piece of music. The presence of sharps or flats in the key signature affects the pitch of certain notes throughout the piece.