I'd say the important thing for this kind of thing is to understand and recognize the different intervals between the notes – that way you can write down your melodies to, well, at least some scale and then transpose it later to whatever key you want.