Realtime erase key command similar to hardware sequencers?


anyone know a method to assign key or midi command to “realtime erase” similar to many hardware sequencers?
You press the erase button and note on the midi keyboard to erase it.

I think almost all hardware seuencers/ drum machines have this kind of function

It would be really convenient to add and erase notes while loop recording