overall updates

This commit is contained in:
joshikannan
2025-11-26 18:24:03 +05:30
parent 12df2e9dc4
commit e71e44319c
35 changed files with 3145 additions and 2404 deletions

View File

@@ -0,0 +1,26 @@
import { useEffect } from 'react';
export const useHotkeyFocus = (ref, hotkey = 'k') => {
useEffect(() => {
if (!ref?.current) return;
const handleKeyPress = (event) => {
const isHotkey = event.key.toLowerCase() === hotkey.toLowerCase();
// CTRL + Hotkey
if (isHotkey && (event.metaKey || event.ctrlKey)) {
event.preventDefault();
ref.current?.focus();
}
// ESC to blur
if (event.key === 'Escape' && document.activeElement === ref.current) {
ref.current.blur();
}
};
document.addEventListener('keydown', handleKeyPress);
return () => document.removeEventListener('keydown', handleKeyPress);
}, [ref, hotkey]);
};