function keyHandler(e) {
    e.preventDefault();
    var login = e.target.classList.contains("login") ? e.target : e.target.closest(".login");

    switch (e.code) {
        case "Tab":
            var partElement = e.target.closest(".part");
            var targetElement = e.shiftKey ? "previousElementSibling" : "nextElementSibling";
            if (partElement[targetElement] && partElement[targetElement].hasAttribute("tabindex")) {
                partElement[targetElement].focus();
            } else if (e.target == document.querySelector(".logins").lastChild) {
                document.querySelector(".part.add").focus();
            } else {
                document.querySelector(".part.search input[type=text]").focus();
            }
            break;
        case "ArrowDown":
            if (login.nextElementSibling) {
                login.nextElementSibling.focus();
            } else {
                document.querySelector(".part.add").focus();
            }
            break;
        case "ArrowUp":
            if (login.previousElementSibling) {
                login.previousElementSibling.focus();
            } else {
                document.querySelector(".part.search input[type=text]").focus();
            }
            break;
        case "ArrowRight":
            if (e.target.classList.contains("login")) {
                e.target.querySelector(".action").focus();
            } else if (e.target.nextElementSibling) {
                e.target.nextElementSibling.focus();
            } else {
                e.target.click();
            }
            break;
        case "ArrowLeft":
            if (e.target.previousElementSibling.classList.contains("action")) {
                e.target.previousElementSibling.focus();
            } else {
                login.focus();
            }
            break;
        case "Enter":
            if (e.target.hasAttribute("action")) {
                this.doAction(e.target.getAttribute("action"));
            } else if (e.target.classList.contains("details")) {
                e.target.click();
            } else {
                this.doAction("fill");
            }
            break;
        case "KeyA":
            if (e.ctrlKey) {
                document.querySelector(".part.add").click();
            }
            break;
        case "KeyC":
            if (e.ctrlKey) {
                if (e.shiftKey || document.activeElement.classList.contains("copy-user")) {
                    this.doAction("copyUsername");
                } else {
                    this.doAction("copyPassword");
                }
            }
            break;
        case "KeyG":
            if (e.ctrlKey) {
                const event = e;
                const target = this;
                dialog.open(
                    helpers.LAUNCH_URL_DEPRECATION_MESSAGE,
                    function () {
                        target.doAction(event.shiftKey ? "launchInNewTab" : "launch");
                    },
                    false
                );
            }
            break;
        case "KeyO":
            if (e.ctrlKey) {
                e.target.querySelector("div.action.details").click();
            }
            break;
        case "Home": {
            document.querySelector(".part.search input[type=text]").focus();
            document.querySelector(".logins").scrollTo(0, 0);
            window.scrollTo(0, 0);
            break;
        }
        case "End": {
            let logins = document.querySelectorAll(".login");
            if (logins.length) {
                let target = logins.item(logins.length - 1);
                target.scrollIntoView();
            }
            document.querySelector(".part.add").focus();
            break;
        }
    }
}
Handle result key presses

@param Event  e    Keydown event
@param object this Result object
@return void