Hello!
You most likely have worn or dirty contacts in the ignition lock cylinder. If you look down inside, youwill see2 metal fingers that contact the pellet in your ignition key when it is in the cylinder. these become worn over time and do not make good electrical contact with the key pellet.
you could try using a computer air duster spray can to clean inside the lock cylinder, or possibly reaching some small tool down inside to bend them outward a little to make better key contact if possible. the usual fix is to have the ignition lock cylinder replaced.
I hope this is helpful; if this answers your question, please click my accept button! thanks!