Sorry, I might have thought this was more advanced than it really is.
You just want to spawn a key when a barrel is destroyed, nothing more? Then just use a ObjectEventTrigger and click on the little button that says Object and choose the barrel also, choose destroyed in the list, then use CTRL+ALT+LMB on a SpawnObject. Does that not work?