If I understand your request, you are looking for a device with a retractable cord. That sound like a retractable badge reel. People wear them to hold their work ID. You may have to use something to substitute the hardware on the back for an adhesive patch so you can fasten it on the machine. Here's one from Amazon. They have tons.
https://www.walmart.com/ip/Baumgarte...Reels/27351843