The Cosmic Key is a device that allows its owner to create portals to anywhere. It was built by Gwildor.
Gwildor was tricked by Evil-Lyn into giving her his prize creation The Cosmic Key to Skeletor, and thus allowing them to enter Castle Grayskull and take over Eternia. As the unwitting cause of Grayskull's defeat, Gwildor endeavored to help He-Man overcome Skeletor by using a prototype Cosmic Key. When the heroes found themselves overwhelmed by Skeletor's army, Gwildor uses the Cosmic Key to help them escape, and the heroes are transported to Earth, leaving Gwildor faced with the task of finding the correct programming on the Key to transport them back before Skeletor gains the power of the universe.
The Cosmic Key is a complex device with numerous switches and buttons, which can be used to programme sonic waves, sounds, music and light patterns which serves to transport its users to the location of their choice.