Add Search bar Keyboard Shortcut

This commit is contained in:
Utkarsh Agarwal
2025-10-18 23:58:41 +05:30
parent 8e549b7304
commit f11efe7278
2 changed files with 21 additions and 0 deletions

View File

@@ -83,6 +83,22 @@ const init = () => {
});
});
window.addEventListener('keydown', function (e) {
const isMac = navigator.userAgent.toUpperCase().includes('MAC');
const isCtrlK = e.ctrlKey && e.key === 'k';
const isCmdK = isMac && e.metaKey && e.key === 'k';
if (isCtrlK || isCmdK) {
e.preventDefault();
searchBar.focus();
}
});
const shortcutK = document.getElementById('shortcut');
shortcutK.textContent = navigator.userAgent.toUpperCase().includes('MAC')
? '⌘ K'
: 'Ctrl K';
dom.toolGrid.addEventListener('click', (e) => {
// @ts-expect-error TS(2339) FIXME: Property 'closest' does not exist on type 'EventTa... Remove this comment to see the full error message
const card = e.target.closest('.tool-card');