The short version
The key of a song is the note that feels like home, plus whether the music around it is major or minor. To find it, hum the note the song wants to end on, match that note on a piano or keyboard app, then decide whether the song sounds major or minor over it. Check your answer against the chords and the final note of the song.
You do not need perfect pitch. You need a way to play single notes (a piano, a guitar or a free keyboard app), a quiet room and a few minutes of the song on repeat.
Step 1: find the home note
Play the chorus and stop it at a random moment. Hum the note that would make the music feel finished. Most listeners land on the same note without thinking, because popular melodies keep returning to it at the end of phrases.
Another way in is the bassline. At the end of a chorus or a verse, the bass usually lands on the home note. Hum along with the lowest part rather than the vocal if the melody keeps moving.
Step 2: match it on the keyboard
Hold the note you hummed, then play notes on the keyboard until one matches. Move a semitone at a time; when you are close, the clash between your voice and the key gets slower before it disappears. The note that matches is your tonic: the first half of the key name.
If you are unsure between two neighbouring notes, play each one while the song is paused on a held chord. The right one sounds settled; the wrong one rubs.
Step 3: decide major or minor
Play your tonic, then the note four semitones above it, along with the song. If that fits, the song is probably major. If the note three semitones above fits better, it is probably minor. In C, that is E for C major and E-flat for C minor.
Mood is a weak shortcut. Plenty of upbeat dance records are in minor keys and plenty of sad ballads are in major keys, so trust the interval over the feeling.
Step 4: check against the chords
Most songs use chords built from the notes of their key. If you found A minor, expect chords such as A minor, C, D minor, E minor, F and G. If the song keeps landing on chords that do not belong, you may have found the relative major or minor instead: A minor and C major share all their notes, so listen again for which chord feels like home.
Some songs change key, often for a final chorus, and some sit in a mode such as Dorian or Mixolydian rather than plain major or minor. Note the key of the section you plan to use rather than the song as a whole.
Step 5: turn it into a Camelot code
Once you have the key, open the BPM and key workspace and choose it from the list. It shows the Camelot code and the neighbouring keys that usually blend well. A minor is 8A, so 7A, 9A and 8B are the first places to look for a partner song.
If the two songs you want to combine are a semitone or two apart, the key transposer shows where a pitch shift would take one of them, and the compatibility checker scores the pairing with tempo included.
When to trust a key database instead
Key-detection software and online databases are quick, but they disagree more often than BPM tools, especially on songs with key changes, detuned recordings or sparse arrangements. Published sheet music is the most reliable written source. Use any database result as a starting point and confirm it by ear with the steps above before you build anything on it.