aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
Diffstat (limited to 'views')
-rw-r--r--views/layout.eta26
1 files changed, 25 insertions, 1 deletions
diff --git a/views/layout.eta b/views/layout.eta
index 85f431c..dd523d1 100644
--- a/views/layout.eta
+++ b/views/layout.eta
@@ -21,7 +21,7 @@ git clone git@github.com:<%= it.repo.owner %>/<%= it.repo.name %>.git</code></pr
<% } %>
</nav>
<form action="/<%= it.repo.owner %>/<%= it.repo.name %>/search" method="get">
- <input type="text" name="q" placeholder="Search…" value="<%= it.q ?? "" %>">
+ <input id="search-input" type="text" name="q" placeholder="Search…" value="<%= it.q ?? "" %>">
<select name="type">
<option value="issues" <%= it.searchType === "issues" ? "selected" : "" %>>Issues</option>
<option value="pullrequests" <%= it.searchType === "pullrequests" ? "selected" : "" %>>Pull requests</option>
@@ -34,5 +34,29 @@ git clone git@github.com:<%= it.repo.owner %>/<%= it.repo.name %>.git</code></pr
<%~ it.body %>
<footer>Generated by cgithub</footer>
+
+ <script>
+ document.addEventListener("keydown", function(e) {
+ let shortcut = "";
+ if (e.ctrlKey || e.metaKey) shortcut += "C-";
+ if (e.altKey) shortcut += "A-";
+ if (e.shiftKey) shortcut += "S-";
+ shortcut += e.key;
+
+ if (shortcut === "Escape") {
+ document.activeElement.blur();
+ return;
+ }
+
+ if (["INPUT", "TEXTAREA", "SELECT"].includes(document.activeElement.tagName)) {
+ return;
+ }
+
+ if (shortcut === "/") {
+ e.preventDefault();
+ document.getElementById('search-input').select();
+ }
+ });
+ </script>
</body>
</html>