I reference “key” and “major scale” in the post on solfège https://functionalanalysis.blog/2017/06/13/solfege/ , but now we’re going to go into it a little bit more.
A key is a framework for organizing notes in a tonal hierarchy. Read about tonality here: https://functionalanalysis.blog/2017/09/26/tonality/
Keys are centered around a tonic pitch and tonic chord. This chord/note is the name of the key. So if something is in E♭ major, the note E♭ is the tonic note, and E♭ major (E♭ G B♭) is the tonic chord. A major scale starts on tonic (do) and goes up in the sequence whole step, whole step, half step, whole, whole, whole, half (wwhwwwh) ending on the same note we started, but up an octave. Using E♭ that comes out to the notes
E♭ F G A♭ B♭ C D E♭
do re mi fa so la ti do
The half step between ti and do is a big part of what makes us recognize the tonic pitch, because the instability of the half step pulls toward do. The pitches that help us recognize major are the major thirds between do and mi and so and ti (and fa and la).
Here’s a piece by Clara Schumann in E♭ major: https://www.youtube.com/watch?v=W4OgUZiWGU8
A piece can be in a major key and still have some notes that are not necessarily from the scale, but most of the notes will probably be, and the important notes and chords will be emphasized, especially at cadences. (If you’re ready to think about cadences try this: https://functionalanalysis.blog/2016/12/21/lesson-1-cadence-and-form/ )
I’m going to get to key signatures, part of how we notate keys, as a separate post after I write the post on minor. Remember that something can be in a key that does not match its key signature!