Hello and thank you for using Justanswer.com,
My name is XXXXX XXXXX I'll be helping you today. Your issue could be from a couple of things. The ignition switch is a definite possibility. The contacts will get coated in carbon and the connection gets faulty. You can normally take the switch apart and clean the contacts, but it is not a simple job and most just replace it. The other things to look at before changing the ignition switch would be:
-Look at the grounds, not just the battery include the engine trans and body main grounds
-Battery connections. It is common for corrosion to form in these. Just loosening them and working them back and forth to break some corrosion off works sometimes.
Hope that will get you on the way to a repair. Please let me know if you have any questions.