Each monster optionally has an 'onDie' hook to be defined or connected to. If it exists the function will be run just before the monster dies.
You could use a function that checks for the other two monsters, and ~not finding them, adds the key to the dying monster's inventory just before death.
BTW: EoB had a "Schrödinger's Gun" in form of the keys you find. On level two for instance, you had one key, and three locks. Whatever door you open, there is a key for the other one somewhere inside... but not if the party keeps the key, and has their thief pick the lock.