vaadin / vaadin/framework

Keydown event frequency

Open
#4,313 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Originally by @MTzukanov


Quote:
"The main problem is, that it's not possible to set a timout (or whatever) between several POST requests to the server-side.
So if a user holds down a shortcut key, e.g. ESC, each 2-3ms the server side will be informed with a POST request.

Example:

private final ShortcutListener escapseShortcutListener = new ShortcutListener("ESC key", KeyCode.ESCAPE, null)
{
    private static final long serialVersionUID = -8080266529606949440L;

    @Override
    public void handleAction(Object sender, Object target)
    {
        // sample code will be called here,
        // but should be not invoked for each 2-3ms
    }
};

So we need a new behavior to react on keyUp/keyDown events inside the shortcut listener.
As long as the button is hold down, only one event should be triggered.
Is this possible in Vaadin?

(Worstcase scenario: If ~ 400-1000 user use shortcuts in an excesive way, the impact on the server-side would be our bottleneck in future.)"


Imported from https://dev.vaadin.com/ issue #12374

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing ShortcutListener and its handleAction callback, then inspect how keydown and keyup events are sent to the server. Confirm the intended behavior from the issue: holding a shortcut should trigger only one event rather than repeated POST requests. No file or test is named in the payload, so the relevant entry point and validation coverage must first be located.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.