They form ionic bonds
Potassium has 1 electron in its outer shell so it wants to lose it to become more stable.
Chlorine has 7 in its outer shell so it wants to gain 1 to be more stable
The potassium donates the 1 electron to Cl
This forms K+ ion and Cl- ion