What determines whether a portal will drop a key as a result of an xmp blast?

AFAIK, destroying resonators at linked portals will sometimes cause a portal key to the remote end to drop.