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

Ignore key modifiers when handling keyboard events #250

Closed
wants to merge 1 commit into from
Closed

Ignore key modifiers when handling keyboard events #250

wants to merge 1 commit into from

Conversation

raushan
Copy link

@raushan raushan commented Apr 20, 2024

This branch adds a set of modifiers that are be ignored when handling keyboard events to avoid accidentally activating better-yt-shorts shorcuts when trying to use system shortcuts.

For example, I noticed that pressing cmd+f/ctrl+f to search for text on the page (e.g. comments on a yt short) also activates the full screen shortcut if you're using the default keybind.

Comment on lines +294 to +299
* The set of modifers that will be checked to determine if a given key should
* be ignored when handling key events.
*
* Note that these correspond to `KeyboardEvent.key` values since `KeyboardEvent.getModifierState`
* does not accept `KeyboardEvent.code` values.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/getModifierState}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mainly thought to point this out since EXCLUDED_KEY_BINDS uses KeyboardEvent.code values and I wanted to make it clear that these values are a bit different since they use KeyboardEvent.key values.

* does not accept `KeyboardEvent.code` values.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/getModifierState}
*/
export const EXCLUDED_KEY_MODIFIERS = ["Alt", "Control", "Meta", "Shift"];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these modifiers are safe to ignore (i.e. ignoring them won't interfere with shorctuts) since they're all included in the set of keys that can't be used for key binds.

This helps to avoid accidentally activating a better-yt-shorts keyboard shortcut when trying to use a system/OS level shorcut.
@raushan raushan closed this Jun 20, 2024
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

Successfully merging this pull request may close these issues.

1 participant