Your melody is almost entirely pentatonic. Also, it reminds me of the song Sakura, from the rhythm and the way you repeat the opening motif.
Is kind of ironic that you are having trouble using the "black keys", because one ways the pentatonic scale is explained to beginners is it is the scale you get when you play only the black keys of the piano.
Let's show your melody notated...
Yellow highlight shows the part that is all C
pentatonic. The blue highlight shows how you transpose that idea, by playing it again but at a lower pitch. That blue part would be in G
pentatonic. Notice the overlap that becomes green. That includes pitches that could be in either C
or G
pentatonic. The second half follows that same design.
People often point out that when playing only the white keys of the piano that can give the C
major scale. However, in your case, you almost entirely avoid playing the B
and F
, which gives us a pitch collection of C D E G A
, which is C
pentatonic.
Many melodies work with a focus on pentatonic portions of a major scale with careful inclusion of the other two "missing" scale degrees (in C
that means careful inclusion of B
and F
.) This is exactly what your melody does. A good example of this, in a famous song, is Stephen Foster's Oh! Susanna.
You should be able to do the same type of melodies, but focused on the black keys. Try playing only the black keys, consider the G♭
as the tonic, and then try to carefully include either the F
or C♭
. (Notice that the C♭
looks like a plain B
natural on the keyboard, that is called enharmonic equivalence, but don't worry about that for now.)
If you transpose your original melody to the black keys in the way I described, it will become...
...notice how it is all black keys except for the few F
naturals that end each phrase.
This will give you two simple approaches: all white keys and all black keys. The "trick" that makes either one work is keeping the melody mostly pentatonic. Pentatonic music can be thought of as a kind of "no wrong notes" music.
You can write music combining black and white piano keys, but you need to either do some music theory study or be very persistent/lucky/intuitive with trial and error to make it work.
You might look into Irving Berlin and what people said about him using only the black keys of the piano. A pentatonic focus is not necessarily a bad thing.