Four sharps sit at the start of every line of music written in E major: F#, G#, C# and D#. That little cluster tells a reader, before a single note is played, that this tune will live on the notes E, F#, G#, A, B, C#, D#. One of those sharps, D#, sits just one key below home on the piano, and it spends its whole life trying to get back there. Much of what makes a melody sound like E major comes from that one restless note and a handful of others that either settle or lean.
A scale is a set of notes arranged in order from a starting note, called the root, up to the same note an octave higher. The major scale is built from a fixed pattern of steps. A half step is the smallest step in Western music, like moving from one piano key to the very next one, black or white. A whole step is two half steps.
The major scale pattern is W - W - H - W - W - W - H. Starting on E:
You might wonder why the second note is F# and not Gb, since they're the same piano key. The rule is simple and kind: each letter from A to G gets used exactly once. E, F, G, A, B, C, D, each appearing one time, with sharps added wherever the step pattern needs them. Call it Gb and you'd have two G's and no F, which makes the music harder to read.
You may also run into Fb major. It sounds identical to E major, but writing it needs eight flats, including double flats. Nobody expects you to use it. E major's four sharps are the friendly spelling, and that's the one you'll see almost everywhere.
Sing or play the scale slowly and pay attention to how each note feels when you stop on it. Three notes feel settled: E, G# and B. Together they make the E major chord, and a melody can rest on any of them without sounding unfinished. E is the most final of all.
The other four, F#, A, C# and D#, feel like they're in motion. Two of them lean especially hard, and they're the notes that give the scale its identity:
Those two half steps, A falling to G# and D# rising to E, are where most of the scale's sense of direction comes from. The bright, happy, resolved sound people describe in major keys is largely the satisfaction of these tensions being released.
Stack every other note of the scale on each degree and you get seven chords. A triad is a three-note chord; a seventh chord adds one more note on top. Roman numerals number the chords from the root, with capitals for major and lowercase for minor:
Notice that B7 contains both leaning notes, D# and A. That's why it pulls so strongly back to E: the chord holds all the scale's tension at once. Try the progression E - C#m - A - B7 - E. Hum along and you'll find your voice naturally wants to land on D# over the B7 and then step up to E as the last chord arrives.
C#m is also the home chord of C# minor, the relative minor of E major. It shares exactly the same seven notes and the same four sharps; it simply treats C# as home instead of E. If your tune starts sounding darker and keeps settling on C#, you've wandered into the relative minor, which is a lovely place to visit mid-song.
A melody announces its key mostly through where it rests and how it gets there. A few habits make E major unmistakable:
A simple shape to sing: B, C#, B, G#, A, G#, F#, then D#, E. It wanders around the home notes, leans on A, and finishes with the leading tone resolving.
E is a natural key on guitar because the low E string is the root itself. You'll find E on the low E (6th) string at frets 0, 12 and 24, and on the A (5th) string at frets 7 and 19. Start a scale shape from the open string or the 12th fret, and use the 7th fret on the A string as a second anchor nearby. Practice landing phrases on those root frets, approaching each one from D# a fret below.
Play a slow loop of B7 to E, on piano, guitar or a backing track. Over the B7, sing or play D# and hold it until it feels uncomfortable. Then step up to E as the chord changes. Do it ten times, then try reaching E from A, G#, F#, and D# instead, a four-note descent and turn. Record your favorite version: that's the last line of your first E major tune.
For the bigger picture, read The Major Scale (Ionian Mode).