TransWikia.com

Which event type is preferable for keyboard interactions, "key up" or "key down"?

User Experience Asked on October 31, 2021

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"?

One Answer

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.

Answered by Benjamin Jex on October 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP