Potassium and hydrogen can be thought of as competitors. Hyperkalaemia tends to be associated with acidosis because as potassium levels rise fewer hydrogen ions can enter the cells
Hypokalaemia with alkalosis
Hypokalaemia with acidosis
Hypomagnesemia commonly causes refractory hypokalemia, due to renal potassium wasting in the loop of Henle. Alcoholics are often hypomagnesemic. This is believed to be due to alcohol-induced renal tubular dysfunction, leading to increased urinary excretion of magnesium. Other factors such as diarrhea, acute pancreatitis, and dietary deficiencies could also play a role

Trimethoprim can cause hyperkalemia by blocking the epithelial sodium channel in the collecting tubule, similar to the action of the potassium-sparing diuretic amiloride. This occurs more commonly in HIV-infected patients who are treated with high doses of trimethoprim, but even normal doses can produce a modest elevation in the plasma potassium concentration.
Thus, patients treated with high-dose trimethoprim require serial monitoring of potassium to avoid serious complications. Trimethoprim also competitively inhibits renal tubular creatinine secretion and may cause an artificial increase in serum creatinine; however, GFR is unchanged.

Hyperkalaemia causes three important clinical abnormalities in patients with pacemakers:

ECG features are present in approximately 66% of patients with severe hyperkalaemia (K+ ≥ 6.5 mmol/l). The ECG may be normal even in severe hyperkalaemia.
Consider the clinical picture alongside ECG – severity of hyperkalaemia, rate of rise and level of acuity of patient. Seek senior help if in doubt.