From 8d66359139b0045fe0a44735d64674ebb92c590d Mon Sep 17 00:00:00 2001
From: Oni-Men <sensyaheis@gmail.com>
Date: Wed, 26 Feb 2020 17:22:43 +0900
Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E3=81=98=E3=83=9B=E3=83=83=E3=83=88?=
 =?UTF-8?q?=E3=82=AD=E3=83=BC=E3=81=8C=E9=80=A3=E7=B6=9A=E3=81=A7=E7=99=BA?=
 =?UTF-8?q?=E5=8B=95=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?=
 =?UTF-8?q?=20(#6082)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* add cooldown to hotkey

* remove blank

* use repeat flag

* format

* Add Repeatable option to Hotkey

* Boolean型のみに

* console.log消すの忘れてた
---
 src/client/scripts/hotkey.ts | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/client/scripts/hotkey.ts b/src/client/scripts/hotkey.ts
index ec627ab15..672dbedde 100644
--- a/src/client/scripts/hotkey.ts
+++ b/src/client/scripts/hotkey.ts
@@ -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();