one can tell from the key signature what key a piece is in so long as one knows whether it is major or minor (see “mode”). for example: a key signature of one sharp is either g major or e minor. the best way to find out which it is would be to see whether the end of the piece is based on g major or e minor. also: if the piece is in the minor key it is very likely that there will be several accidentals in the piece which sharpen the 7th note of the scale (in this case changing a lot of the ds to d sharps).