How does a fly land upside down on the ceiling?
On approaching the ceiling, and while still flying right side up, flies extend their forelegs over their heads till they can grab a landing spot with the suction cups in their feet. Their momentum then enables them to swing their hind legs up, like a gymnast on a trapeze.