Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
82
rated 0 times [  85] [ 3]  / answers: 1 / hits: 60096  / 8 Years ago, thu, july 21, 2016, 12:00:00

I have been trying to understand JavaScript keypress, keydown, keyup and input events. But I found them quite confusing. Could someone please point out the exact differences? Also I would like to know do all of them get triggered when the user paste a piece of text.


More From » input

 Answers
4

According to jQuery docs:



The keypress event is sent to an element when the browser registers keyboard input. This is similar to the keydown event, except that modifier and non-printing keys such as Shift, Esc, and delete trigger keydown events but not keypress events. Other differences between the two events may arise depending on platform and browser.


The keyup event is sent to an element when the user releases a key on the keyboard.


The oninput event it's an event that triggers whenever the input changes.



However the input event is not supported in IE version below 9. In that case, you could use proprietary event onpropertychange, it does the same as oninput.


But in your case, you could use the paste and change event together. You should use change too because paste only happens on browsers that support it on an explicit paste.


[#61295] Monday, July 18, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
karladaijahf

Total Points: 78
Total Questions: 123
Total Answers: 89

Location: Liechtenstein
Member since Wed, Dec 8, 2021
3 Years ago
;