Well to figure out what key you're in, while for example you're just jamming the way I do it when I don't remember if I changed a key (This won't happen live, it happens to me usually when I just daze off during playing). You have to find the note that gives you a feeling of "stability." You are trying to find the 1st degree of the scale/mode you were playing in and you can ear it out by imagining it's the end of a song and you have to finish it off with a chord but first try finding the note then work out the chord.
But of course jazz especially contemporary jazz is really foofed up, so you might just be playing atonal stuff, which is cool if done right.
I don't think we let you down
So come Messiah show us now, now