9

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?

Nafeez Abrar
  • 1,045
  • 10
  • 27

1 Answers1

8

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.

isherwood
  • 58,414
  • 16
  • 114
  • 157
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331