3.5mm headphone as button or switch

3.5mm jacks have an extra pin that detects a plug being inserted. A lot of 3.5mm female ends made for PCB will be clear and you can get a good look at how they work. Just google some up and look for 5 pin varieties.