i was playing with some friends and i felt like i was sort of stuck in the jam because i dont know what keys sound good together. except for the ones that are the same obviously
ive only been playing about 6-7 months and i just wanted to have a way to know if theres some sort of rule to go by

You need to learn I IV V (The perfect (neutral) intervals) in every key. ADE, BEF#, CAB, DGC, EAB, FA#C, GCD. And also relative major/minor. If you have A major, take the VI of that scale, compose the minor scale of it, and you have the same notes. A major = F# minor.

If this is over your head then keep asking questions about it, this is a very good foundation to use to start writing and jamming.
well what advise i can say is that to be creative in a jam it doesnt necessarily always involve changing keys, i mean you can but what i think works well is just knowing what notes our in the scale and what scales apply to your chord progression, if your going off of a simple I-V-III, just go off the root note and go crazy along the fret board but you must know your scales. and where you can go on the fretboard and also about the sure sound of the piece.
sorry if this didnt necessarily answer your question fully
i was just trying to give advice lol
ill have to look more into the perfect interval thing as its a bit over my head
thanks for for helping me out(both of you)