The invention relates to a key structure and an electronic device and belongs to the technical field of electrons. The key structure comprises a housing, a key cap, an electronic switch, a limiting plate and a rocking bar, wherein the electronic switch is installed in the housing, and an opening is formed in the position, corresponding to the electronic switch, of the housing, the rocking bar comprises a head portion and a rod portion, the rod portion is hinged to the housing, the head portion is provided with a through hole, a key contact is arranged at the position, corresponding to the electronic switch, of the head portion, and the length of the rod portion is greater than or equal to a preset value; a clamping hook corresponding to the through hole is formed in the bottom of the key cap, the key cap is installed in the opening, the clamping hook penetrates through the through hole of the rocking bar, and the bottom of the key cap is attached to the head portion of the rocking bar.Plug pins are arranged at two ends of the limiting plate, a gap is formed between the two plug pins, the plug pins of the limiting plate are inserted into the gap between the clamping hook and the head portion of the rocking bar, and the key contact is located in the gap. By adopting the key structure and the electronic device, the problem is solved that the key structure cannot be normally used.