Not completely different keys, but different starting points (notes) within the key/scale (synonymous for our purposes).
To directly answer your question, they either have an amazing natural talent, or they work extremely hard at it and study. They either learn about arranging and orchestration, or they listen to a lot of music (a lot), and use their ears and emulate what they hear until it makes sense to them. So try things. They might not work, but the only way to do it (without composition classes) is to try and try again, then examine the results.
There are all kinds of materials here at FP (and all over the Web and YouTube) to help you learn the rules of music (so you can break them). But the point is to keep doing it, and pay attention to those ideas that come to you, and continue to excercise your composition muscles (so they don't atrophy).
Tips--A few ideas... Do you know your scale degrees? Start your melody on D#, but try starting your bassline a 5th below it (or a 4th above). Use a D# as the root of your chord, but then invert the chord (change the order of the notes without changing the notes themselves). Program a funky syncopated beat, then align your bass notes only with the bass drum hits in your rhythm (even if, especially if, the kick rhythm doesn't promote a strong beat "1"). These ideas will get you started with moving off of a D#/D#/D#/D# paradigm.