When should I use keydown and keyup?
Asked Answered
F

1

10

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?

Fancyfree answered 24/10, 2012 at 13:5 Comment(1)
This is a good question, and I haven't yet seen a good answer for it anywhere online. UX StackExchange has a similar question more focused on the "user experience" side of this question: Which event type is preferable for keyboard interactions, "key up" or "key down"?Precedential
M
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.

Masseur answered 24/10, 2012 at 13:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.