Keys will often ring in the ultrasonic and poorly mimic the frequencies that a lot of bats use.
If you have a population of bats that hunt near you, the bugs will typically just drop. Like, just drop to the ground as fast as they can.
They know the sound of hunting bats and your keys may be just close enough to that sound that they think they're being hunted. So they do the best that they can to get out of the way and go with gravity. At least, that's my theory.
Fun little thing to do as a bet or with the kiddos.