diff --git a/_layouts/default.liquid b/_layouts/default.liquid index 3f4af10e524a..e519ec2d93ef 100644 --- a/_layouts/default.liquid +++ b/_layouts/default.liquid @@ -73,5 +73,6 @@ {% include scripts/jekyll_tabs.liquid %} {% include scripts/back_to_top.liquid %} {% include scripts/search.liquid %} + diff --git a/assets/js/shortcut-key.js b/assets/js/shortcut-key.js new file mode 100644 index 000000000000..f8de525aac8e --- /dev/null +++ b/assets/js/shortcut-key.js @@ -0,0 +1,11 @@ +// Check if the user is on a Mac and update the shortcut key for search accordingly +document.onreadystatechange = () => { + if (document.readyState === "interactive") { + let isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0; + let shortcutKeyElement = document.querySelector("#search-toggle .nav-link"); + if (shortcutKeyElement && isMac) { + // use the unicode for command key + shortcutKeyElement.innerHTML = '⌘ k '; + } + } +};