Western music divides the octave into twelve equal semitones: C, C#, D, D#, E, F, F#, G, G#, A, A#, B — then it repeats an octave higher. A key is just a group of seven of those notes that sound settled together. C major is all the white keys; C minor flattens the 3rd, 6th and 7th (C D E♭ F G A♭ B♭).
Intervals — the distance between two notes in semitones — carry the emotion. A minor 3rd (3 semitones) is sad, a major 3rd (4) is bright, a perfect 5th (7) sounds powerful and resolved, and a tritone (6) is tense and perfect for a build.
The practical rule producers actually enforce: pick a key before you write, so your chords, bass, melody and 808 slides never clash. Keep the same interval relationships and you can transpose the whole idea anywhere.