What electrical component serves or can serve this function?
Pretty easy with opamps. Start off with a differentiator amplifier, then a comparator.

https://www.electronics-tutorials.ws/opamp/opamp_7.html

https://www.electronics-tutorials.ws/opamp/op-amp-comparator.html