mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 11:37:02 +03:00
Fixed mod keys when setting keybinding
This commit is contained in:
@@ -318,16 +318,18 @@ function activateKeybindChange(element: HTMLElement) {
|
||||
*/
|
||||
function keybindKeyPressed(element: HTMLElement, e: KeyboardEvent) {
|
||||
var key = e.key;
|
||||
|
||||
if (["Shift", "Control", "Meta", "Alt"].indexOf(key) !== -1) {
|
||||
document.addEventListener("keydown", (e) => keybindKeyPressed(element, e), {once: true});
|
||||
} else {
|
||||
let button = element.querySelector(".trigger-button");
|
||||
let option = element.getAttribute("sync-option");
|
||||
|
||||
// Don't allow keys which are already listened for by youtube
|
||||
let restrictedKeys = Array.from("1234567890,.jklfcbm/<> -").concat(["Shift"]);
|
||||
let restrictedKeys = "1234567890,.jklftcbmJKLFTCBM/<> -";
|
||||
if (restrictedKeys.indexOf(key) !== -1 ) {
|
||||
element.querySelector(".option-hidden-section").classList.add("hidden");
|
||||
button.classList.remove("disabled");
|
||||
alert("The key '" + key + "' is already used by youtube. Please select another key.");
|
||||
alert("The key " + key + " is already used by youtube. Please select another key.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -337,7 +339,7 @@ function keybindKeyPressed(element: HTMLElement, e: KeyboardEvent) {
|
||||
if (key === otherKeybind) {
|
||||
element.querySelector(".option-hidden-section").classList.add("hidden");
|
||||
button.classList.remove("disabled");
|
||||
alert("The key '" + key + "' is bound to another action. Please select another key.");
|
||||
alert("The key " + key + " is bound to another action. Please select another key.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -358,6 +360,7 @@ function keybindKeyPressed(element: HTMLElement, e: KeyboardEvent) {
|
||||
statusKey.innerText = key;
|
||||
|
||||
button.classList.remove("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user