mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +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) {
|
function keybindKeyPressed(element: HTMLElement, e: KeyboardEvent) {
|
||||||
var key = e.key;
|
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 button = element.querySelector(".trigger-button");
|
||||||
let option = element.getAttribute("sync-option");
|
let option = element.getAttribute("sync-option");
|
||||||
|
|
||||||
// Don't allow keys which are already listened for by youtube
|
// 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 ) {
|
if (restrictedKeys.indexOf(key) !== -1 ) {
|
||||||
element.querySelector(".option-hidden-section").classList.add("hidden");
|
element.querySelector(".option-hidden-section").classList.add("hidden");
|
||||||
button.classList.remove("disabled");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +339,7 @@ function keybindKeyPressed(element: HTMLElement, e: KeyboardEvent) {
|
|||||||
if (key === otherKeybind) {
|
if (key === otherKeybind) {
|
||||||
element.querySelector(".option-hidden-section").classList.add("hidden");
|
element.querySelector(".option-hidden-section").classList.add("hidden");
|
||||||
button.classList.remove("disabled");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,6 +361,7 @@ function keybindKeyPressed(element: HTMLElement, e: KeyboardEvent) {
|
|||||||
|
|
||||||
button.classList.remove("disabled");
|
button.classList.remove("disabled");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will trigger the textbox to appear to be able to change an option's text.
|
* Will trigger the textbox to appear to be able to change an option's text.
|
||||||
|
|||||||
Reference in New Issue
Block a user