Skip to content

Commit 40a7509

Browse files
記録するホットキーはレートリミット式にする
1 parent b104485 commit 40a7509

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/frontend/src/scripts/hotkey.ts

+10
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,24 @@ const matchPatterns = (ev: KeyboardEvent, action: Action) => {
131131
});
132132
};
133133

134+
let lastHotKeyStoreTimer: number | null = null;
135+
134136
const storePattern = (ev: KeyboardEvent, callback: CallbackFunction) => {
137+
if (lastHotKeyStoreTimer != null) {
138+
clearTimeout(lastHotKeyStoreTimer);
139+
}
140+
135141
latestHotkey = {
136142
which: [ev.key.toLowerCase()],
137143
ctrl: ev.ctrlKey || ev.metaKey,
138144
alt: ev.altKey,
139145
shift: ev.shiftKey,
140146
callback,
141147
};
148+
149+
lastHotKeyStoreTimer = window.setTimeout(() => {
150+
latestHotkey = null;
151+
}, 500);
142152
};
143153

144154
const parseKeyCode = (input?: string | null) => {

0 commit comments

Comments
 (0)