I don't think that a definite solution can be given because no matter how you try, these actions will always distract you unless you can stare at the exam paper and ignore anything else which sounds easy on paper (screen?) but hard in reality,
All I can say is just try and increase your 'recovery time' or something, try not to dwell on this things and just focus on the paper. When you start getting distracted, pinch yourself and focus on the paper. Always focus on the paper and maybe the clock but mostly on the paper.
This is just my opinion.