In .Net, what's the best choice for entering a code by pressing a key on a keyboard, keyboard, or keyboard?

Are these two events the same or are there differences that should be considered when encoding a keyboard?

+3
source share
7 answers

My answer here is based only on experimenting with various applications, and not in programming as such.

Handle the key. Let this be a trigger for your logic. This is what the user expected based on interaction with other applications.

For example, try a key in Notepad and you will see that DOWN triggers a reaction in Notepad. He is not waiting for UP.

+5
source

, .Net , , . Keydown - . - . - , , , keydown , , .

+3

" .NET".

, . , - , , , , . - , , KeyDown.

KeyDown - . KeyUp , .

+2

, :

- , , .

. , , "", . , , , key up. 2- , , .

; . :)

+1

, , , .

, key up, 5 , , .

(: .net, "key up" "key down" .)

0

, : keydown. keydown ctrlPressed=true; keyup ctrlPressed=false;

keyPressed - .

Such a system allows you to include things like CTRL + K + C ala Visual Studio

0
source

I use KeyDown all the time, because then I can use e.Handled = True and stop the keyevent to move from the text box to the container and down to the eventque if I want. You can also use e.Handled in KeyUp, but then "until late", because the key you entered will be displayed in the text box, and you will have to take it manually if, for example, you want the user to not enter numbers in the text field.

0
source

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


All Articles