Posted before. It uses 3 magnets for a very soft tactile curve. The magnets are basically in a row, one in the plunger, two in the case. They are tiny. The magnet axis are 90 degree to the plunger movement axis. The one in the plunger repells the two others.
Switching is done with a tiny reed contact. Optical would be fine too. I'm not sure what is cheaper in quantities.
It will not be free from wear though, you still need a plastic case to confine the movement.
Got the idea when I remembered that I had these Lego train couplings as a kid and how it felt when you moved two magnets of the same polarity along each other.