[A11y] Keyboard accelerators for toolbar buttons.

This commit is contained in:
hackademix 2020-05-31 18:11:51 +02:00
parent 162dd17a7a
commit bbcf630866
2 changed files with 15 additions and 1 deletions

View File

@ -98,6 +98,20 @@ addEventListener("unload", e => {
}
}
let keyHandlers = {
"r": "reload",
"o": "options",
"p": "temp-trust-page",
"f": "revoke-temp",
"G": "enforce",
"T": "enforce-tab",
};
window.addEventListener("keydown", e => {
let buttonId = keyHandlers[e.key];
if (buttonId) document.getElementById(buttonId).click();
}, true);
let navigate = e => {
let sel = e.code === "ArrowUp" ? ":last-child" : "";
document.querySelector(`.sites tr.site${sel} input.preset:checked`).focus();

View File

@ -497,7 +497,7 @@ var UI = (() => {
customizer.classList.toggle("closed", false);
let temp = preset.parentNode.querySelector("input.temp");
customizer.onkeydown = e => {
if (e.shiftKey) return true;
switch(e.code) {
case "Tab":
if (document.activeElement === lastInput) {