Skip to content

[BUG] Unable to preventDefault on "meta + enter" sequences, so browser treats enter as click #338

@JoeVanGundy

Description

@JoeVanGundy

Describe the bug

  • A user just clicked a menu item.
  • They then use the meta + enter combo to run an unrelated task.
  • Since they used the enter key, the browser treats it as a click event and clicks the menu item, then react-hotkeys run the handler.

I'd like to preventDefault, or something similar, on all browser events if and only if the user used the meta+enter combo.

How are you using react hotkeys components? (HotKeys, GlobalHotKeys, IgnoreKeys etc)
GlobalHotKeys

Expected behavior
I'm using the meta + enter combo. A menu item is currently focused. If the user enters the combination, I would expect the enter key shouldn't fire the browser click event on the menu item.

Platform (please complete the following information):

  • Version of react-hotkeys: 2.0.0
  • Browser [e.g. chrome, safari]: chrome
  • OS: [e.g. iOS]: Mac

Include the smallest log that includes your issue:

The meta + enter combo is matched long after the menu item has already been clicked.
image

What Configuration options are you using?
None as I was unable to find anything that could help me here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions