Although literally speaking, keydown means to press a key, the fundamental difference between the two is that the system uses keydo
Wn returns the code of the keyboard, which is then translated by the translatemessage function into a character, and the value of the character is returned by keypress.
Therefore, in keydown, the keyboard code is returned, while in keypress, the ASCII characters are returned.
If you only want to read characters, use keypress. If you want to read the status of each key, use keydown.
It is wrong to say that keydown is press, keypress is press and release. What if you keep pressing the key? At this moment, real estate continues
Generate keydown and keypress.
Onkeypress can only be triggered when a single key is pressed, and for shift, ALT, Ctrl, and
Assembly. For example, CTRL + F1 does not trigger this message. The message it processes may be wm_char.
Onkeydowm can capture all these buttons.
It actually processes the wm_keydown message.
It can be understood that onkeydown is the superset of onkeypress.
One difference is that keypress is a reaction to simple characters.
Does not respond to shift, F1 functional buttons
Keydown can all be reflected.