Detect which momentary switch caused a STM32 cpu to wakeup
I don't know the details of this ST part, so I'll assume your description of it is correct.

The processor should wake up very soon after either button is pressed.  This should be especially true if it has a internal RC oscillator.  Even if you need to run from a crystal eventually for accuracy reasons, perhaps you can have the part start from a internal RC, then switch to the crystal later.  There are micros that can do such things, although I don't know if yours is one of them.

In any case, you read both inputs as soon as possible after wakeup.  Unless there is something unusual about this ST micro, that should be from a ms to a few 10s of ms from the button press.

To guarantee the line is still low, use a capacitor to keep the line low for up to 100 ms after the button is released.

For example, let's say the guaranteed logic low input level is 20% of the supply voltage.  The line is pulled up with a resistor, and has a capacitor to ground.  The button shorts the line to ground.  The line therefore floats high, and is actively forced to ground when the button is pressed.  When the button is released, the voltage exponentially decays towards the supply.

Decaying to 20% of the final value happens in 0.22 time constants.  Lets say you want to guarantee the line looks low for 100 ms after a button press.  That means the RC time constant must be 450 ms.  With 100 k&Omega; pullup, the capacitance would need to be 4.5 &micro;F.  So a 4.7 &micro;F 10 V cap would do nicely.

In summary, here is the circuit: