You can buy an electronic key from Mazda dealers. It will be a nice small paperweight..........See below
There is a good chance your car does not have the full wiring harness needed for an electronic key to work. This is the first thing you should check out. Unless you are very knowledgeable or have strong masochistic tendencies, you really don't want to get into replacing or modifying the wiring harness.
If the car does have the harness you can probably buy kits for the door locks (check J.C Whitney, for example) or you can get Mazda parts from the dealer or a junker. You will need the latch mechanisms and the actuating relay.
Good luck!
Source(s):
J.C. Whitney website, Mazdaforum.com, personal experience with electric locks and coded keys.