The sentence you quoted is a decent simplification but you probably shouldn’t take it too literally. It’s not really that the melody uses exactly seven notes. It is that these seven notes form the harmonic context that the chords and melody sits in. Normally that also means that the notes in question will be the most common ones in both chords and melody, but you can certainly use other notes as well.
A key is really an “I know it when I hear it” thing. The notes used are just one of many clues working together.
A key is really an “I know it when I hear it” thing. The notes used are just one of many clues working together.