Microcontroller ON/OFF

We are using Arduino UNO and it has 2 inputs which is 2 key keypad which we are using for our application. Now i want to use that keypad for ON/OFF of microcontroller also.How i can do that? I want to ON controller power supply when i press keypad key and then i will use those key for my application also and then if i key for long time or press both keys it will OFF, i.e. power supply cut off. This is like our old keypad mobile phones which has 1 key for Mobile phone ON and that same key we can use for receiving call also. How can i do that for my Arduino UNO?
I thought of latch circuit but its BC547 transistor always needs to be high so if i connect 1 key for base then that key i cant use for my application later.
Kindly help me to solve and i think this thing is not possible to software. I want to completely OFF my controller not switch into power down mode.

MOSFETS are easy to damage with ESD, and I did not test this circuit but it does seem to work in simulation.

It is a latch. When the gate of the P-channel MOSFET (PMOS) is pulled low the N-channel MOSFET is pulled high and will hold the PMOS gate low after the pushbutton is open.