Keep humming the melody and try to identify the note which brings it to a pleasing conclusion.
First listen to the song a couple of times, or until you have memorized the melody.
Next pick up the guitar, or the piano (you don’t have to pick up the piano). Hum the melody gently and as you hum try to bring the melody to a satisfying conclusion. Every song has an ending. It is like a curtain-fall. It tells you that it is over and it fills you with satisfaction. It does not leave you hanging in the air (although there are some rare songs which end with an inconclusive note). So, keep humming the melody and try to identify the note which brings it to a pleasing conclusion. You might fail the first time, but with practice you will be able to find the key note quickly.
Now locate this key note on the 3rd string (G string) of the guitar, or play the keys of the piano and find the note. After you are confident that you have found the right note, play the major chord related to the note in the same pattern you play the A major or B major chord (on guitar). Does it match? If you feel like it does not suit the melody, play the minor chord in the same pattern you play the A minor or B minor chord (on guitar). If you listen carefully, you know which chord matches. Consequently, you will understand whether it is a major key or a minor key.
Once you have determined the key, start adding chords from the related chord family.