in src/js/other-websites/inpage_menu.js [14:49]
async function handleKeydownEvents(e) {
const relayInPageMenu = getRelayMenuEl();
const clickableElsInMenu =
relayInPageMenu.querySelectorAll("button, a, input");
const watchedKeys = ["Escape", "ArrowDown", "ArrowUp"];
const watchedKeyClicked = watchedKeys.includes(e.key);
if (e.key === "ArrowDown") {
preventDefaultBehavior(e);
activeElemIndex += 1;
}
if (e.key === "ArrowUp") {
preventDefaultBehavior(e);
activeElemIndex -= 1;
}
if (e.key === "Escape") {
preventDefaultBehavior(e);
iframeCloseRelayInPageMenu();
}
if (clickableElsInMenu[activeElemIndex] !== undefined && watchedKeyClicked) {
return clickableElsInMenu[activeElemIndex].focus();
}
// Limit the lower bounds of the active element tab index (Don't go below 0)
if (activeElemIndex <= 0) {
activeElemIndex = 0;
}
// Limit the upper bounds of the active element tab index (Don't go below however many tab-able elements there are)
if (activeElemIndex >= clickableElsInMenu.length) {
activeElemIndex = clickableElsInMenu.length - 1;
}
}