A height adjusting mechanism suitable for a keyboard is provided, and the keyboard is placed on a flat surface and has a casing. The height adjusting mechanism includes a fixing piece, a cylinder, a first gear and a second gear. The fixing piece is disposed on the casing and has a container and at least a supporting part that extends into the container. The cylinder has at least a spiral guide on its sidewall and the supporting part slides along the spiral guide when the cylinder rotates. In addition, the first gear is assembled to the cylinder so that the first gear and the cylinder can rotate simultaneously. The second gear and the first gear are meshed with each other so that the second gear can drive and rotate the first gear to adjust the relative distance between the casing and the bottom of the cylinder.