mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-29 21:37:34 -07:00
同じホットキーが連続で発動しないように (#6082)
* add cooldown to hotkey * remove blank * use repeat flag * format * Add Repeatable option to Hotkey * Boolean型のみに * console.log消すの忘れてた
This commit is contained in:
parent
8965eca121
commit
8d66359139
1 changed files with 10 additions and 1 deletions
|
@ -12,14 +12,22 @@ type action = {
|
|||
patterns: pattern[];
|
||||
|
||||
callback: Function;
|
||||
|
||||
allowRepeat: boolean;
|
||||
};
|
||||
|
||||
const getKeyMap = keymap => Object.entries(keymap).map(([patterns, callback]): action => {
|
||||
const result = {
|
||||
patterns: [],
|
||||
callback: callback
|
||||
callback: callback,
|
||||
allowRepeat: true
|
||||
} as action;
|
||||
|
||||
if (patterns.match(/^\(.*\)$/) !== null) {
|
||||
result.allowRepeat = false;
|
||||
patterns = patterns.slice(1, -1);
|
||||
}
|
||||
|
||||
result.patterns = patterns.split('|').map(part => {
|
||||
const pattern = {
|
||||
which: [],
|
||||
|
@ -77,6 +85,7 @@ export default {
|
|||
const matched = match(e, action.patterns);
|
||||
|
||||
if (matched) {
|
||||
if (!action.allowRepeat && e.repeat) return;
|
||||
if (el._hotkey_global && match(e, targetReservedKeys)) return;
|
||||
|
||||
e.preventDefault();
|
||||
|
|
Loading…
Reference in a new issue