After testing, it is clear that the order in which the events are executed is: keydown->keypress->keyup.
But press a button continuously, will always trigger: KeyDown keypress. The KeyUp will be triggered until you lift the button.
But for some special keys, the events that can be triggered in the browser are different.
There are a few points to note:
1. Like keypress: The input of non-characters such as the shift CTRL key is not triggered.
2. When the Enter key encounters a form form, when there is only one text box and enter enter, the form is automatically submitted, which only triggers keydown,keypress two events.
3. When listening to the KeyDown event, the Enter key encounters a form form and target= ' _blank ' when some browsers intercept the page because:
Because KeyDown in the press to enter the time has been triggered, but then the program is still processing logic, in the processing of the submission, the browser will be considered to be the program opened a new page, not considered the user behavior opened, causing the browser to block the opening of new pages, The solution is: Switch the monitoring KeyDown to monitor keypress.
Summarize:
KeyDown from the performance point of view is to press any key. The event that is generated before the text box is not displayed to the text box if the character is pressed. KeyDown is triggered when a key is pressed.
KeyPress occurs when the key is released, and the character is entered into the text box. Keys that are pressed and released with an input character will be triggered.
Keyboard event KeyDown keypress KeyUp Difference