KeyEventArgs.Handled vs KeyEventArgs.SupressKeyPress

What is the difference between using

e.Handled = true 

and

 e.SuppressKeyPress = true 

I read that SuppressKeyPress calls e.Handled, but does it do it?

+6
source share
2 answers

According to this blog: New Keyboard APIs: KeyEventArgs.SuppressKeyPress :

The problem is that "Handled" does not care about waiting for WM_CHAR messages already created in the message queue - so setting Handled = true does not prevent KeyPress from appearing.

In order not to break anyone who currently received e.Handled = true, we needed to add a new property, SuppressKeyChar. If we went the other way, if the "circulation" with the key suddenly started, in fact we can break down people who accidentally installed this set true.

+9
source

It simply prohibits user input for all pending button presses. that is, in the TextBox, not only the Handled event is set to true, user input is suppressed and does not appear in the text field if you type very quickly and immediately press many buttons.

+2
source

Source: https://habr.com/ru/post/898083/


All Articles