Capturing the Deleted Text in TextBox when Backspace or Delete Key is Pressed

If you have ever wanted to get the deleted character/text from a textbox when the Backspace key or the Delete key on the keyboard is pressed, you would know that there is no easy way to do that. You can easily get the typed text (using any of the keyboard events like KeyDown, KeyPress etc.), but not the deleted text.

However it is not impossible to achieve this. All you need is some event/method that executes before the KeyDown event is fired. And fortunately there are many.

For this demo I will show you how to do that using the ProcessKeyMessage , but you can use any of the others as well (e.g. WndProc etc.) … Read the full article »