-
Notifications
You must be signed in to change notification settings - Fork 118
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
Fix repeated actions, and modifier check #914
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -73,7 +73,7 @@ export const isHotkeyMatchingKeyboardEvent = (e: KeyboardEvent, hotkey: Hotkey, | |||
return false | |||
} | |||
} else { | |||
if (metaKey !== meta && ctrlKey !== meta && keyCode !== 'meta' && keyCode !== 'ctrl') { | |||
if (metaKey !== meta && ctrlKey !== meta) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #909 - combinations such as meta+k
end up in keyCode
equalling k
rather than the modifier
@@ -65,7 +65,9 @@ export default function useHotkeys<T extends HTMLElement>( | |||
parseKeysHookInput(keys, memoisedOptions?.splitKey).forEach((key) => { | |||
const hotkey = parseHotkey(key, memoisedOptions?.combinationKey) | |||
|
|||
if ((isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions?.ignoreModifiers) || hotkey.keys?.includes('*')) && !hasTriggeredRef.current) { | |||
if (isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions?.ignoreModifiers) || hotkey.keys?.includes('*')) { | |||
if (isKeyUp && hasTriggeredRef.current) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #898 - the check now only runs during keyup
, hence now allowing repeating keys to be pressed
Thank you so much for your work! I'll have a look through it. |
@JohannesKlauss did a brief run through the code and tested these changes against my expectations for the implementation in Amie.
Lemme know if there's anything else needed to get these changes in and a new version up!