Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Dynamically sets the search shortcut key based on the user's platform #2461

Merged
merged 6 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _layouts/default.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<meta http-equiv="refresh" content="3; url={{ redirect }}">
{% endif %}
{% include head.liquid %}
<script src="{{ '/assets/js/shortcut-key.js' | relative_url }}"></script>
ajyey marked this conversation as resolved.
Show resolved Hide resolved
</head>

<!-- Body -->
Expand Down
13 changes: 13 additions & 0 deletions assets/js/shortcut-key.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Check if the user is on a Mac and update the shortcut key for search accordingly
(function () {
var isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
ajyey marked this conversation as resolved.
Show resolved Hide resolved
document.addEventListener('readystatechange', function () {
if (document.readyState === 'interactive') {
george-gca marked this conversation as resolved.
Show resolved Hide resolved
let shortcutKeyElement = document.querySelector('#search-toggle .nav-link');
if (shortcutKeyElement && isMac) {
// use the unicode for command key
shortcutKeyElement.innerHTML = "&#x2318; k <i class='ti ti-search'></i>";
}
}
});
})();