A key structure, comprising: a circuit board; a membrane disposed on the circuit board and electrically connected to the circuit board; a positioning frame disposed on the membrane; a sensor module (140, 140a) disposed on the membrane and electrically connected to the circuit board, wherein the sensor module (140, 140a) comprises a light emitting device and a light detector; a scissor leg (150, 150a) connected to the positioning frame and adapted to move up and down relative to the positioning frame; and a first key cap and a second key cap alternatively detachably disposed at the scissor leg and spaced with the positioning frame, wherein the first key cap and the second key cap have a reflective plane and a shaft component, the reflective plane faces the membrane, the shaft component is extended from the reflective plane and penetrates through the scissor leg and the positioning frame to abut the membrane, and the sensor module is aligned with the reflective plane; characterized in that, the shaft component of first key cap has an elastic component such that the elastic component abuts the membrane to switch to a digital mode; then when the first key cap is pressed, the elastic component generates a non-linear deformation to squeeze the membrane to trigger a digital control signal detecting a press stroke of the first key cap relative to the membrane; the first key cap having the shaft component with the elastic component is able to be replaced by the second key cap, wherein the shaft component of the first key cap is different from the shaft component of the second key cap, and wherein the shaft component of the second key cap has an elastic component such that the elastic component abuts the membrane to switch to an analog mode; then when the second key cap is pressed, the elastic component generates a linear deformation to trigger an analog control signal through a press stroke of the second key cap relative to the membrane detected by the sensor module. a circuit board; a membrane disposed on the circuit board and electrically connected to the circuit board; a positioning frame disposed on the membrane; a sensor module (140, 140a) disposed on the membrane and electrically connected to the circuit board, wherein the sensor module (140, 140a) comprises a light emitting device and a light detector; a scissor leg (150, 150a) connected to the positioning frame and adapted to move up and down relative to the positioning frame; and a first key cap and a second key cap alternatively detachably disposed at the scissor leg and spaced with the positioning frame, wherein the first key cap and the second key cap have a reflective plane and a shaft component, the reflective plane faces the membrane, the shaft component is extended from the reflective plane and penetrates through the scissor leg and the positioning frame to abut the membrane, and the sensor module is aligned with the reflective plane; characterized in that, the shaft component of first key cap has an elastic component such that the elastic component abuts the membrane to switch to a digital mode; then when the first key cap is pressed, the elastic component generates a non-linear deformation to squeeze the membrane to trigger a digital control signal detecting a press stroke of the first key cap relative to the membrane; the first key cap having the shaft component with the elastic component is able to be replaced by the second key cap, wherein the shaft component of the first key cap is different from the shaft component of the second key cap, and wherein the shaft component of the second key cap has an elastic component such that the elastic component abuts the membrane to switch to an analog mode; then when the second key cap is pressed, the elastic component generates a linear deformation to trigger an analog control signal through a press stroke of the second key cap relative to the membrane detected by the sensor module.