A key retaining lock is a lock design in which the key cannot be removed from the lock without the lock being returned to the locked state. This is most often used on padlocks to require that the shackle be closed before the key can be removed.
Nonkey retaining conversely means the key can be removed while the lock is in the unlocked position.
These are also sometimes called one key pull (key retaining) vs two key pull nonkey retaining.
Those that prefer key retaining seek it to make sure that the key stays in the lock until the lock is secured. This acts as a reminder that the lock is not secured forcing it to be locked up to remove the key. On the flip side, some prefer to be able to leave the lock unlocked during store hours, for example, and prefer the nonkey retaining.
In key-retaining padlocks, the movement of the plug and cam to release the shackle forces in ball bearings that hold the cam in place until the shackle is returned to the locked position. This can be seen as a security measure but it also prevents the lock from being lost or stolen, or snapped shut behind someone.
In key retaining cabinet locks, the key remains in the lock until the door or drawer is locked. Management can use this feature to make sure cabinets are locked at all times whereby cabinets that are not locked can be easily identified with a key hanging in the lock.
Tubular locks (also called Ace or Barrel style locks) are easy to visually identify if they are key retaining or nonkey retaining.