Fixed mod keys when setting keybinding

This commit is contained in:
Joe-Dowd
2020-03-20 19:39:37 +00:00
parent da5a3841bd
commit c78e2cd214

View File

@@ -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;
}
@@ -359,6 +361,7 @@ function keybindKeyPressed(element: HTMLElement, e: KeyboardEvent) {
button.classList.remove("disabled");
}
}
/**
* Will trigger the textbox to appear to be able to change an option's text.