From 083935920cb068bc3094c7bea89d43695d758056 Mon Sep 17 00:00:00 2001 From: Erayd Date: Thu, 24 Oct 2019 13:42:14 +1300 Subject: [PATCH] Implement home / end keys for popup (#187) --- src/popup/interface.js | 15 +++++++++++++++ src/popup/searchinterface.js | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/popup/interface.js b/src/popup/interface.js index b8c4c6f..8fd8542 100644 --- a/src/popup/interface.js +++ b/src/popup/interface.js @@ -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; + } } } diff --git a/src/popup/searchinterface.js b/src/popup/searchinterface.js index 96d89fa..078876b 100644 --- a/src/popup/searchinterface.js +++ b/src/popup/searchinterface.js @@ -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; + } } } })