Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't listen for colon #19344

Open
mhus opened this issue May 9, 2024 · 1 comment
Open

Can't listen for colon #19344

mhus opened this issue May 9, 2024 · 1 comment

Comments

@mhus
Copy link

mhus commented May 9, 2024

Description of the bug

Listen on grid to press colon did not work there is no Key.COLON and even key.of(":") will not work.

Expected behavior

Get a event on pressing ":"

Minimal reproducible example

ui().addShortcutListener((event) -> doSomething() , Key.of(":")).listenOn(component);

Versions

  • Vaadin / Flow version: 24.3.9
  • Java version: 21.0.2
  • OS version: Macos
  • Browser version (if applicable): Chrome
  • Application Server (if applicable):
  • IDE (if applicable):
@mcollovati
Copy link
Collaborator

Colon is not listed in the keycode values (https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_code_values). So, this is probably the reason why there's no enumeration entry.

I think the problem here is that the colon key is often shared with another key, and you have to press also a modifier (for example SHIFT).
On my keyboard layout, I have colon and period sharing the same button; to output a colon, I have to press SHIFT.

So, back to your code, I can make it work by activating also SHIFT on the shortcut, for example

ui().addShortcutListener((event) -> doSomething() , Key.of(":"))
   .withShift()
   .listenOn(component);

This looks like a workaround, but I currently don't know if we can do something on Flow to better handle these special cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔎 Investigation
Development

No branches or pull requests

3 participants