When should I use keydown and keyup?

5.6k Views Asked by At

Which event should be used for key press handling key-down/key-up? It is sure that in both case the program will run successfully. But which one will be more user-friendly?

1

There are 1 best solutions below

0
On

It depends on you. There is no such best practice. Both are used as per the need of your program and as per the convenience of the user.

keyup Fires when the user releases a key, after the default action of that key has been performed.

keydown Fires when the user depresses a key. It repeats while the user keeps the key depressed.

Check out this page describing the differences.