For this to work, though, ALL of the following conditions must be met at once:
- The locked warp must allow NPCs.
- The key must be on a layer that gets hidden as soon as you use it; in other words, the key's "death" must trigger an event that hides the key.
- There must be at least one other NPC on-screen at the time that you unlock the warp.
I haven't tried it with every NPC, but it's worked with all of the ones I did try it with (SMB3 coin, both Donut Blocks, Mother Brain glass, Ripper, spawned Rinkas, Bullet Bill). If there are multiple NPCs on-screen, sometimes it picks randomly between them, maybe it'll pick a favorite and stick with it, or pick a couple of random ones while ignoring others. I have no idea what decides that.
Here's the test level in the screenshots if you want to mess around with it. The warp is locked, the key is on its own layer, and there's a random NPC off to the side that appears in your hands. The conveyor belt is on the Default layer with no additional properties added to it.
Nothing special happens with Link or Yoshi, but a blue or black Yoshi will be able to fly with nothing in their mouth until you dismount. That part doesn't even depend on the above conditions though, just that the warp is locked.