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

by pass browser shortcut on keydown/keyup? #446

Open
mysolo opened this issue Sep 18, 2023 · 3 comments
Open

by pass browser shortcut on keydown/keyup? #446

mysolo opened this issue Sep 18, 2023 · 3 comments

Comments

@mysolo
Copy link

mysolo commented Sep 18, 2023

good morning,

We use hotkey.js as follows:

hotkey.unbind()
hotkeys(shortcut.key, shortcut.options , event)

with options: { keydown: false, keyup: true }

in order to receive only events on a keyup and avoid repetition events when keys remain pressed. This works well on shortcuts not used by the browser.
However, on command + Z, command + X, command + C, etc., for example, the browser takes over.
If you don't use keydown/keyup, it works, but we receive continuous events if the keys remain pressed.
Is there a way of receiving a single event for each key pressed, or of unbinding the browser keys when the same shortcut is used?

@Ainias
Copy link

Ainias commented Sep 29, 2023

As far as I understand the documentation, you can check for the event.type inside your callback. If it is keydown, return false to prevent the browser default. If it is keyup, do your normal callback

@rouilj
Copy link

rouilj commented Oct 6, 2023

Check event.repeat. If it is true your getting an auto-repeating key and you can ignore the event. If it's false handle the event.

@oleksandr-danylchenko
Copy link

oleksandr-danylchenko commented Jul 12, 2024

check for the event.type inside your callback
If it is keyup, do your normal callback

Unfortunately, on the keyup event isn't even reported into the hotkeys when it's system-related 🤷🏻‍♂️🤷🏻‍♂️🤷🏻‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants