A keyboard for an electronic device, wherein the keyboard comprises at least the following: a keyboard assembly, comprising a circuit board unit and a key; and a keyboard frame assembly, comprising an outer metal frame, an inner metal frame, and a key avoidance hole, wherein the inner metal frame is connected to the outer metal frame, the key avoidance hole penetrates through the outer metal frame and the inner metal frame, the keyboard assembly is connected to the inner metal frame, the inner metal frame is located between the outer metal frame and the keyboard assembly, the inner metal frame is configured to carry the keyboard assembly, and the key is disposed in correspondence with the key avoidance hole, so that the key is exposed from the key avoidance hole and thereby accessible by a user; and wherein the keyboard assembly is detachably connected to the inner metal frame; wherein the keyboard further comprises an adaptation piece, the adaptation piece comprises a first component and a second component, the first component is disposed on the inner metal frame, and the first component and the second component are fastened to connect the circuit board unit and the inner metal frame; wherein the circuit board unit comprises a circuit board, a metal sheet, and a backlight module, the circuit board is disposed on a side that is of the metal sheet and that faces the inner metal frame, the backlight module is disposed on a side that is of the metal sheet and that faces away from the inner metal frame, the circuit board comprises a first avoidance hole, the metal sheet comprises a second avoidance hole, the backlight module comprises a third avoidance hole, the first component is inserted into the first avoidance hole and the second avoidance hole, and a cap portion of the second component is accommodated in the third avoidance hole and abuts against a surface that is of the metal sheet and that faces away from the circuit board. a keyboard assembly, comprising a circuit board unit and a key; and a keyboard frame assembly, comprising an outer metal frame, an inner metal frame, and a key avoidance hole, wherein the inner metal frame is connected to the outer metal frame, the key avoidance hole penetrates through the outer metal frame and the inner metal frame, the keyboard assembly is connected to the inner metal frame, the inner metal frame is located between the outer metal frame and the keyboard assembly, the inner metal frame is configured to carry the keyboard assembly, and the key is disposed in correspondence with the key avoidance hole, so that the key is exposed from the key avoidance hole and thereby accessible by a user; and wherein the keyboard assembly is detachably connected to the inner metal frame; wherein the keyboard further comprises an adaptation piece, the adaptation piece comprises a first component and a second component, the first component is disposed on the inner metal frame, and the first component and the second component are fastened to connect the circuit board unit and the inner metal frame; wherein the circuit board unit comprises a circuit board, a metal sheet, and a backlight module, the circuit board is disposed on a side that is of the metal sheet and that faces the inner metal frame, the backlight module is disposed on a side that is of the metal sheet and that faces away from the inner metal frame, the circuit board comprises a first avoidance hole, the metal sheet comprises a second avoidance hole, the backlight module comprises a third avoidance hole, the first component is inserted into the first avoidance hole and the second avoidance hole, and a cap portion of the second component is accommodated in the third avoidance hole and abuts against a surface that is of the metal sheet and that faces away from the circuit board.