I use one of these small handgun safes sold by Sentry. Lighted four-button keypad, key override if needed. Automatic opening, spring loaded door. Not heavy armor for sure, but will keep curious children at bay. Also available in a "biometric" version.
They use AA battery pack, but I've found that a single 9 volt battery will operate the safe for about two years.
I have the safe attached to the side of my nightstand next to the head of the bed, with the hinge facing down. When the combination is entered, the door swings open and stays open, exposing the gun, but the gun does not fall out.
Therein lies my old duty pistol, Glock model 21, with a Sure-Fire X300 light attached.
Sentry Safe Gun Safe, 0.08 cu. ft., Electronic QAP1E | Zoro.com