I wanted to elaborate a little bit more so that the OP does not develop misconceptions. It is the potassium atoms not potassium ions that color the flame purple. While I was writing the answer, another poster emphasized the same point.
Caveat: In ordinary Bunsen burner type flames, emission from calcium, Sr, and Ba is from molecular compounds not atoms. The story of atomic emission is only true for alkali metals. The flame temperature is quite low in Bunsen burners. You need special flames to "see" the atomic emission of Ca, Ba, Sr.
Assume the processes when you introduce KCl in the flame:
a) The salt has to melt KCl (l)
b) It has to vaporize KCl (gas)
c) It has to decompose into constituents. Flames have free electrons, so potassium ions are converted to potassium atoms.
d) From the thermal energy of the flame, potassium atoms are excited. Once they de-excite, you see the violet/lilac color. It is an ultrafast process!
e) The flame temperature is so "low" on the scale of universal temperatures (stars, Sun) is that only 1-2% atoms get excited.
Now you may ask, what about the chlorine atoms, well, they emit in the deep ultraviolet and we cannot see them. The flame temperature is so low that it cannot excite chlorine atoms.
Keep in mind it is not a single wavelength. If you were lucky enough, you could use a pocket spectroscope and see red and violet lines (plus a persistent yellow line of sodium contamination).
Actually the strongest lines for potassium are 764 and 769 nm which are deep red. Many humans cannot see this deep red. So your flame would rather be deep red. Potassium atoms also emit less strongly at the other extreme end of the spectrum, corresponding to deep purple lines around 404 nm. The resulting "mix" of wavelengths appears to our eyes as lilac color!