After the disastrous effects of leaving the Warp Gate open during the Zerg invasion of Aiur, Protoss scientists set to work on countermeasures against future incursions. To prevent these countermeasures from harming their own kind, Gatekeys were created alongside them.
Whenever someone wants to use a gate platform, they will need to use a Gatekey to both activate the structure and deactivate the defenses (Stargate - SG-1: Auto-dialer and G.D.O.). Special built-in biometric and psionic sensors are within the Gatekeys to prevent others from using them. If anyone or anything tries to use the Protoss portal network without the keys, the countermeasures will either return them back to the original gate or to unknown places depending on the destination's importance.