Safeguarding Quantum Key Distribution Through Detection Randomization