feat: working search redirect

This commit is contained in:
2025-10-29 16:30:00 +13:00
parent 167a72f5a3
commit 13be240226
2 changed files with 42 additions and 2 deletions

View File

@ -145,6 +145,30 @@
}
});
// Global keyboard shortcut for search (Cmd+K on Mac, Ctrl+K on Windows/Linux)
document.addEventListener('keydown', function(event) {
// Check if user is typing in an input field
const activeElement = document.activeElement;
const isInputField = activeElement && (
activeElement.tagName === 'INPUT' ||
activeElement.tagName === 'TEXTAREA' ||
activeElement.contentEditable === 'true'
);
if (isInputField) {
return; // Don't trigger shortcut when typing in input fields
}
// Check for Cmd+K (Mac) or Ctrl+K (Windows/Linux)
const isMac = /Mac/.test(navigator.platform);
const isCorrectModifier = isMac ? event.metaKey : event.ctrlKey;
if (isCorrectModifier && event.key === 'k') {
event.preventDefault();
window.location.href = '/search';
}
});
</script>
</body>
</html>