As far as I am aware, from all the people I have helped, there are only 2 causes of muscle cramps/spasms/twitches. The first is magnesium, which is a mineral important for hundreds of different body functions, and greatly deficient in our diet.
However, what seems to be less known in health circles, even though it should be super obvious because it is well known in athlete circles, is too little salt/too much water. Which is a problem for many people due to insane and pointless salt restrictions, and equally insane 'eight cups of water a day' recommendations, neither of which are based on Science at all.
Worse still, many people have weak adrenals due to calorie restriction and other stressors, so they will be wasting salt in their urine.
I experienced horrible muscle cramps, twitching, spasms, and even numbness for over a year because I listened to experts who don't know anything. If you want to know all the answers to health problems, get my book. Its only a buck, and if amazon let me keep it free, I would.