Skip to content

Commit

Permalink
Merge pull request #914 from animify/main
Browse files Browse the repository at this point in the history
Fix repeated actions, and modifier check
  • Loading branch information
JohannesKlauss authored Jan 28, 2023
2 parents 89e355a + 1bc401d commit b71cdbf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/useHotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

maybePreventDefault(e, hotkey, memoisedOptions?.preventDefault)

if (!isHotkeyEnabled(e, hotkey, memoisedOptions?.enabled)) {
Expand Down
2 changes: 1 addition & 1 deletion src/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
return false
}
}
Expand Down

1 comment on commit b71cdbf

@vercel
Copy link

@vercel vercel bot commented on b71cdbf Jan 28, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.