When implementing keyboard interactions, platforms provide two kinds of event: "key up" and "key down". For example:

Therefore, when implementing a keyboard interaction, the developer must choose when the interaction is fired. For example:

  • In a slideshow app, the user can use the arrow keys to move through the slideshow. But should it go to the next slide when the right arrow key is pressed down, or when it is released again?
  • In a video player, the user can hit the spacebar to pause/resume. But should it pause when the spacebar is pressed down, or when it is released again?

The universal provision of both "key up" and "key down" events suggests that the answer is not simple: that, for some situations, "key down" is more appropriate, but for others, "key up" is better.

However, I can find no guidance on this. There are many descriptions of the meaning of "key up" and "key down", but none on how to tastefully choose between them for a given use-case.

In what situations should I prefer a "key up" event? In what situations should I prefer "key down"?

  • I don't see how this question relates to user experience? This is a programming problem, to which the answer is very dependant on what you are trying to achieve. I would suggest looking on Stack Overflow for an answer, but don't post this question on there as it's too generic.
    – musefan
    Jul 17, 2020 at 10:28
  • 1
    @musefan it's not a programming problem. I know how to implement keyboard interactions. The question is whether "key up" or "key down" interactions lead to a better user experience. Jul 17, 2020 at 11:32
  • The decision of which to use largely depends on the functionality you are trying to achieve. The answer to which will be very much a technical one, not one that is based on the user experience. The only part relating to user experience is that the function does what the user expects it to do. Even if you can put up a convincing argument that proves your question is related to UX, you would still need to make your question about a specific scenario in order to be answered.
    – musefan
    Jul 17, 2020 at 12:13
  • 1
    @musefan Actually, I think this can be answered from an accessibility point of view. Which event should trigger something is not simply a programming decision but has implications for accessibility.
    – Tsundoku
    Jul 17, 2020 at 12:51
  • 1
    @musefan Your examples sound like usability anti-patterns.
    – Tsundoku
    Jul 17, 2020 at 14:33

1 Answer 1


A good rule of thumb is to consider whether the action in question would be desirable to repeat without lifting your finger from the key.

For your examples, if I wanted to see a slide that was much further down the page then it would be better to register the press as soon as the key is pushed down AND to let me hold it down instead of pressing the same down key 20 times to get to where I wanted to be.

The opposite would be true for your video player's pause/resume feature. I wouldn't want to press the spacebar and accidentally hold it for too long so that it would pause & then resume again by the time I let go.

  • Interestingly, YouTube, Netflix, and VLC all repeatedly pause+unpause when holding the spacebar down! 🤔 Oct 15, 2020 at 10:12
  • I like the principle - if it's an action that you can "do an arbitrary amount of", then a natural interaction is to hold a key down for a length of time proportional with how much I want to do. And this necessitates acting on keydown. Oct 15, 2020 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.