commit 53af2b74909c73f7620ebaa9de2050e600286e68
parent da9ad43ec7dad3ad4efeed2361068ae491831977
Author: breadcat <breadcat@users.noreply.github.com>
Date: Fri, 10 Jul 2026 11:21:34 +0100
Support Ctrl+Enter for opening search results in a new tab
Diffstat:
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/readme.md b/readme.md
@@ -39,6 +39,7 @@ Then access the server via a web browser, the default port is 8080.
* Database backup and vacuum support
* `tag=!`, `tag=!123` and `tag=x,value=!` for duplicating previously applied tags
* Chainable `/and/tag/tag2/value2` filter matching
+* `Ctrl+Enter` to open search results in a new tab
## Limitations
* SQLite requires cgo, which requires gcc. Build/run with `CGO_ENABLED=1`
diff --git a/static/search-box.js b/static/search-box.js
@@ -0,0 +1,21 @@
+const form = document.getElementById("search-form");
+const input = form.q;
+
+let openInNewTab = false;
+
+input.addEventListener("keydown", function (e) {
+ openInNewTab = e.ctrlKey && e.key === "Enter";
+});
+
+form.addEventListener("submit", function (e) {
+ e.preventDefault();
+
+ const url = "/search/" + encodeURIComponent(input.value);
+
+ if (openInNewTab) {
+ window.open(url, "_blank");
+ openInNewTab = false;
+ } else {
+ window.location.href = url;
+ }
+});
+\ No newline at end of file
diff --git a/templates/_header.html b/templates/_header.html
@@ -48,10 +48,11 @@
</ul>
<div id="search-container">
- <form onsubmit="event.preventDefault(); window.location.href='/search/' + encodeURIComponent(this.q.value);">
+ <form id="search-form">
<input type="text" name="q" value="{{.Query}}" placeholder="Search...">
</form>
</div>
+<script src="/static/search-box.js" defer></script>
</nav>