Secure communication protocols are becoming increasingly important, e.g. for internet-based communication. Quantum key distribution (QKD) allows two parties, commonly called Alice and Bob, to generate a secret sequence of 0s and 1s called a key that is only known to themselves. Classically, Alice and Bob could never be certain that their communication was not compromised by a malicious eavesdropper. Quantum mechanics however makes secure communication possible. The fundamental principle of quantum mechanics that taking a measurement perturbs the system (unless the measurement is compatible with the quantum state) also applies to an eavesdropper. Using appropriate protocols to create the key, Alice and Bob can detect the presence of an eavesdropper by errors in their measurements. As part of the QuVis Quantum Mechanics Visualisation Project, we have developed a suite of four interactive simulations that demonstrate the basic principles of three different QKD protocols. The simulations use either polarised photons or spin 1/2 particles as physical realisations. The simulations and accompanying activities are freely available for use online or download, and run on a wide range of devices including tablets and PCs. Evaluation with students over three years was used to refine the simulations and activities. Preliminary studies show that the refined simulations and activities help students learn the basic principles of QKD at both the introductory and advanced undergraduate levels.