2002 honda civic stalling out

2002 Honda Civic stalls out 2 to 3 times every time I drive it turn and off and back on starts up fine not quite sure what the problem is

Start the engine and while it’s idling wiggle the ignition key.

If the engine shuts off, the ignition switch is faulty.

Tester

There’s a fuel injection/engine relay on Civics somewhere near that vintage (but not sure if it is exactly that one) that can fail intermittently too. If your year is one of those affected by this same relay problem, and the ignition switch idea above doesn’t solve the problem, might just want to replace the relay on a flyer. Apparently it is inexpensive and easy to replace.