So, your car doesn't crank over but if you pull the key out, leave and come back later it'll crank then start?
The first thing I'd check is the battery cables, are they both tight at the battery?
When it doesn't start is there any security light on the cluster?
Does this problem only occur when you use your keyless entry key? If your spare (non-keyless) key works fine then I think you already figured out the problem and ignore all the above.
The microswitch on the shifter won't stop the starter from working, it'll stop the key from turning off(IIRC).
But if the PRNDL switch on the transmission goes wonky for some weird reason, you could try moving the shifter while you hold the key to start.
One other complete shart in the dark would be bad/poor connection somewhere, I've seen lots of problems behind the LH kick panel at the lowest connector(corrosion), and below the driver's seat(LH)(under the carpet) there's a connector plug that corrodes in extreme cases and I had one car that had something loose under the dash near the fuse box. A handful of cars had a broken wire or 2 along the wiring harness on the front of the engine, usually causing charging issues, but the wire going to the starter solenoid could be in that bundle too.
And....Years ago a few work cars wouldn't start when it was cold out. Turned out to be a relay or two under the hood. They were 2017's.
Could also be the starter but usually those either work or don't.
It's kinda hard to diagnose something through the interwebs.
__________________________________________
View my fuel log 2014 Mirage SE wussie cvt edition. 1.2 automatic: 37.7 mpg (US) ... 16.0 km/L ... 6.2 L/100 km ... 45.3 mpg (Imp)