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

Fix repeated actions, and modifier check #914

Merged
merged 2 commits into from
Jan 28, 2023

Conversation

animify
Copy link
Contributor

@animify animify commented Jan 17, 2023

@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!

@vercel
Copy link

vercel bot commented Jan 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
react-hotkeys-hook ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 17, 2023 at 4:13PM (UTC)

@@ -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) {
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@animify animify changed the title Fix 909 and 898 Fix repeated actions, and modifier check Jan 17, 2023
@JohannesKlauss
Copy link
Owner

Thank you so much for your work! I'll have a look through it.

@JohannesKlauss JohannesKlauss merged commit b71cdbf into JohannesKlauss:main Jan 28, 2023
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.

2 participants