Being an amateur, with no academic curriculum, I don't know how to choose the right key for a "classical" piece I imagine.
I hear the melody in my head, usually with harmony together; maybe there are also modulations, and so on. The piece seems pleasant, I play with it rearranging themes, or whatever. Bus or train commuting time, with the associated unpitched noises, is great to find musical ideas and add them in my mind. Usually I am able to name the Roman numerals of most chords, or at least have a clear idea of how they should play. I don't think about the names of the notes, just about the intervals. So, to say, my mind's image has no key yet decided: I still haven't named the notes yet.
And then, I go to the computer, or the keyboard, to notate it - and my inner music does not correspond to any key! Not strange, since I don't have absolute pitch. And the problem becomes: which tonality should I chose to write? I usually stick to the nearest and easiest one for me to follow (so, for example, if what I hear is found on the keyboard to be a somewhat flat C#major, I adjust my inner image to go to Cmajor). If I have to choose between enharmonic keys, I choose the one with flats, the number of added alterations is usually smaller.
I am sure this is a VERY questionable method for most of you, and that you strongly disagree!
However, apart from obvious considerations (instruments' ranges, or ease of execution): are there general principles to decide the right key for a piece after the "mind's image" stage? Should the key be obvious, and I'm just not sufficiently musical?
Sorry if the question seems to naive to most of you, or if it's in the wrong topic (I assume that in case the adminstrators will reposition or cancel the post).