Implement home / end keys for popup (#187)

This commit is contained in:
Erayd
2019-10-24 13:42:14 +13:00
committed by GitHub
parent 33ff35f018
commit 083935920c
2 changed files with 26 additions and 0 deletions

View File

@@ -218,5 +218,20 @@ function keyHandler(e) {
this.doAction(e.shiftKey ? "launchInNewTab" : "launch");
}
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.focus();
target.scrollIntoView();
}
break;
}
}
}

View File

@@ -114,6 +114,17 @@ function view(ctl, params) {
);
}
break;
case "End": {
if (e.target.selectionStart === e.target.value.length) {
let logins = document.querySelectorAll(".login");
if (logins.length) {
let target = logins.item(logins.length - 1);
target.focus();
target.scrollIntoView();
}
}
break;
}
}
}
})