key signatures are written at the beginning of each line of music. this helps the player to remember what the key signature is. the time signature, however, is only written at the beginning of the piece (the order is: clef – key signature – time signature). sometimes music changes key (modulates) during a piece. if the music is going to stay in the new key for some time the composer may decide to change the key signature. another reason for changing the key signature might be that the music has modulated to a key like g sharp major with eight sharps (including a double sharp). it is easier to read the music if it is written in a flat major (4 flats).