2025-07-11 13:06:17 +05:30
|
|
|
import { useMouseNoteStore } from "../../store/useUIToggleStore";
|
|
|
|
|
|
2025-07-11 12:31:00 +05:30
|
|
|
const actionNotes: Record<string, string> = {
|
|
|
|
|
'left+CONTROL': 'Box Select',
|
|
|
|
|
'left+SHIFT': 'Multi Select',
|
|
|
|
|
'middle+CONTROL': 'Zoom In',
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-11 13:06:17 +05:30
|
|
|
|
|
|
|
|
export function mouseActionHelper() {
|
|
|
|
|
const setNotes = useMouseNoteStore.getState().setNotes;
|
|
|
|
|
|
2025-07-11 12:31:00 +05:30
|
|
|
const activeKeys = new Set<string>();
|
|
|
|
|
|
|
|
|
|
function updateNotesFromKeys() {
|
|
|
|
|
const sortedKeys = Array.from(activeKeys).sort();
|
|
|
|
|
const leftKey = ['left', ...sortedKeys].join('+');
|
|
|
|
|
const middleKey = ['middle', ...sortedKeys].join('+');
|
|
|
|
|
const rightKey = ['right', ...sortedKeys].join('+');
|
|
|
|
|
|
2025-07-11 13:06:17 +05:30
|
|
|
setNotes({
|
2025-07-11 12:31:00 +05:30
|
|
|
Leftnote: actionNotes[leftKey] || '',
|
|
|
|
|
Middlenote: actionNotes[middleKey] || '',
|
|
|
|
|
Rightnote: actionNotes[rightKey] || '',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleKeyDown(event: KeyboardEvent) {
|
|
|
|
|
activeKeys.add(event.key.toUpperCase());
|
|
|
|
|
updateNotesFromKeys();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleKeyUp(event: KeyboardEvent) {
|
|
|
|
|
activeKeys.delete(event.key.toUpperCase());
|
|
|
|
|
updateNotesFromKeys();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.addEventListener('keydown', handleKeyDown);
|
|
|
|
|
window.addEventListener('keyup', handleKeyUp);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
window.removeEventListener('keydown', handleKeyDown);
|
|
|
|
|
window.removeEventListener('keyup', handleKeyUp);
|
|
|
|
|
};
|
|
|
|
|
}
|