Skip to content

Commit 76dafdb

Browse files
committed
feat: add the ctrl+k shortcut to open search modal
1 parent 03f62c1 commit 76dafdb

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

static/js/search-shortcut.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Keyboard shortcut: Ctrl+K / Cmd+K opens the Boost Gecko search modal.
3+
*/
4+
(function () {
5+
'use strict';
6+
7+
document.addEventListener('keydown', function (e) {
8+
if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
9+
e.preventDefault();
10+
var searchBtn = document.getElementById('gecko-search-button');
11+
if (searchBtn) searchBtn.click();
12+
}
13+
});
14+
})();

templates/base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@
430430
{% flag "v3" %}
431431
<script src="{% static 'js/carousel.js' %}" defer></script>
432432
<script src="{% static 'js/dialog.js' %}" defer></script>
433+
<script src="{% static 'js/search-shortcut.js' %}" defer></script>
433434
{% endflag %}
434435

435436
{% block footer_js %}{% endblock %}

0 commit comments

Comments
 (0)