This is entirely dependent on the dexterity and strength of the child, but for a long gun such as a pump, or even an AR, you could have it locked, but not loaded, and make it ready at the time you need it.
In the rare circumstance a friend or family member's child is in my place, I sincerely...