I use the TextChanged event of a textbox.
for instance I have the text in the textbox:
“a b”- 2 spaces between a,b
I go in the middle of the 2 spaces, and hit backspace. I can not check by comparing the new text with the old which key was pressed (if backspace or delete was pressed, the newtext is the
same “a b”-1 space between letters.
How can I check which key was pressed?
Why do you care? If you’re handling the
TextChangedevent, you’re not supposed to care what about the text was changed, just the fact that it was.If you need to care about what specifically was changed, you need to handle a lower-level event, like
KeyDown: