To make a key. First of all you need a nylon cord or even a shoe lace will do. It needs to be long enough to be connected to you and the treadmill at the same time. You can buy a clip that attaches to you whenever you're on the treadmill. It will need to be one with a hole in. This way you can put the cord or lace through the hole and tie it so it can't detach from the clip.
Use the same technique with a magnet. There should be a small hole on one side of the magnet. You tie your cord through the hole in the magnet and tie it so it can't fall off. Once you've made it you need to test it. Make sure the treadmill is off and then attach the magnet. While the magnet is on turn on the treadmill and an instruction to move the belt and it should work. Keep it at a very slow speed while you test it.
Attach the safety key to your clothing and see if it has enough tension for it to come off. This is what should happen when you run and you come off or the stop switch is pressed on the treadmill. If that works then you have a working treadmill safety key. It is unfortunate that some won't work at all without the key attached but I suppose it's necessary.
Treadmill keys are not all universal. The one at my local gym doesn't have one you could make, although the treadmill is commercial in nature. There are so many different parts to a treadmill that it may be something you could buy an extra one, when you buy the machine to begin with. I certainly couldn't be without my treadmill for very long as I like to keep in shape.
If you can't find one easily or make a key for your treadmill, I wouldn't try and open the treadmill up as you will void the warranty and there is the danger of electrocution. You might have to call an expert out if needed to which will incur an expense. But treadmills are expensive anyway so there might be a good idea to have someone trained to see it.