I have a mechanical switch that I'd like to use as a signal source for a digital input of a microcontroller. The switch is normally closed, and I'd like to detect the switch being opened as quickly as I reasonably can, while also removing the effects of mechanical bouncing as the switch is opened. That is, I'd like the very first edge of the input signal to flip the state of the output signal towards the microcontroller and for that state to be held for a given duration even if the input signal bounces for a while after the initial edge.
Here's an illustration of what I'd like to see on a transition from closed to open. I chose an arbitrary polarity for the signals, but any polarity would do for my application.
I'm not really concerned with accurately detecting when the switch gets closed again, so it'd be fine if the output state changing in that direction had a fair bit of delay to the input signal first changing.
For the steady state it'd be ideal if the output was different depending whether or not the switch is open or closed, but for my application it'd also be OK if the output went back to its idle state after not detecting an edge for a while, just as long as it's easy to make the duration it's held in the activated state as long as I need it to be.
I feel like this should be achievable with at most a schmitt trigger, resistors and capacitors, and maybe a diode, but I haven't quite managed to work out how to achieve what I need with those, so I'd appreciate any thoughts pointing me in the right direction.