use keydown to handle shortcut key

This commit is contained in:
codetypes committed 2024-09-26 15:28:02 +08:00
1 parent 3be15ee116
commit 085dd49f75
4 files changed
+24 -25

No files matched your search

+2 -3
View File
@@ -13,17 +13,16 @@ const hotkey = (key: string) => {
return key.toLowerCase();
};
export const useKeyUp = (
export const useKeyDown = (
keyFilter: KeyFilter,
target: Target,
eventHandler: (event: KeyboardEvent, key: KeyType) => void,
option?: Options
) => {
option = option || {};
option.events = ["keyup"];
option.target = target;
option.exactMatch = true;
return useKeyPress(keyFilter, eventHandler, option);
return useKeyPress(keyFilter, (e, key) => !e.repeat && eventHandler(e, key), option);
};
export const Hotkey = {