A magnetically levitating key structure comprises a mounting frame (10, 10a, 10b, 10c) and a keycap (20). The mounting frame (10, 10a, 10b, 10c) includes a keycap mounting hole (110), two first recesses (12), and two first magnetic elements (13). The keycap mounting hole (110) is surrounded by several inner wall surfaces (11). The two first recesses (12) are formed in two of the inner wall surfaces (11). The two first magnetic elements (13) are each firmly held in one of the two first recesses (12). The keycap (20) comprises several side surfaces (21), two second recesses (22), and two second magnetic elements (23). The two second recesses (22) are formed in two of the side surfaces (21). The two second magnetic elements (23) are each firmly held in one of the two second recesses (22).The keycap (20) is held in a non-pressed position by the magnetic attraction between the first two magnetic elements (13) and the second two magnetic elements (23). Its upper surface is constantly positioned above the upper surface of the mounting frame (10, 10a, 10b, 10c). When the keycap (20) is pressed down, the magnetic attraction provides a force to reset it.At least one inner wall surface (11) of the receiving frame (10) forms an upper upright surface (111), an inclined surface (112) and a lower upright surface (113), wherein the inclined surface (112) is arranged between and connected to the upper upright surface (111) and the lower upright surface (113), while at least one side surface (21) of the keycap (20) forms an upper side surface (211), an inclined side surface (212) and a lower side surface (213), wherein the inclined side surface (212) is arranged between and connected to the upper side surface (211) and the lower side surface (213), wherein in the unpressed state of the keycap (20) the inclined side surface (212) rests against the inclined surface (112).