hi can u plz explain what exactly is staying in the key note......... if we have a chord progression of E C and D then is it necessary that when i am soloing all my notes have to be withing the E scale (any of the 7 modes) because here it is the key note by what i understand. Please correct me if i am wrong.
^He probably meant power chords, placing the song nicely in the E natural minor scale.

The thing with modes is that the progression determines the mode, not the position or pattern. You're playing in E minor, so you can't play D Mixo or G Ionian over that progression; it is simply called E natural minor.

No, it is not vital that you only use the notes E F# G A B C D. While those notes are the safest, chromatic, not key notes may add a lot of flavor to your piece. However, even scale tones may sound bad. For instance, F# is in key, but is not a note I would recommend holding for long over the C chord; it would sound better over D since F# is the major third of D.
Every (nearly) song has a key. The key is chosen based on what makes the
most sense for how the fundamental harmony (chord progression) resolves.
You can think of the "key" as being the major or minor scale that
is chosen as the basis to write the piece of music. Being "in key" generally means
the note is in the scale of the key (major or minor scale).

There is absolutely no requirement that all the notes of every chord come from
the scale's key. Many of the chords do, but many (if not most) songs will
have chords with notes outside the key. There's not even a requirement that
the song stay in a single key. Quite often it will go through different keys. In
fact "requirement" is probably a word you should abandon altogether for music.
Music theory has no real requirements, only explanations.

The chords C, D and E cannot possibly all be "in key". There is no key that has
3 sequential major chords.

Scale are NOT notes you "have to use". You can use any note, any time you want.
You should think of them as structures that define how each note functions
when it's used in the context of the scale. Even notes not in the scale proper
still have useable functions when you're improvising or playing.