feat: add keyboard shortcuts 1-9, 0 to switch camera groups

Keys 1-9 switch to camera groups 1-9 (sorted by order), key 0 switches
to the 10th group. Shortcuts are ignored when viewing a single camera
(selectedCameraName is set) and do not interfere with text input fields
(handled by useKeyboardListener's built-in focus detection).

https://claude.ai/code/session_018vH9fGSi5McLLa47GEiZJC
This commit is contained in:
Claude 2026-03-22 10:37:54 +00:00
parent f48ae049f1
commit 3043aa4d5b
No known key found for this signature in database

View File

@ -65,6 +65,29 @@ function Live() {
return false;
});
useKeyboardListener(
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
(key, modifiers) => {
if (!modifiers.down || !config || selectedCameraName) {
return false;
}
const groups = Object.entries(config.camera_groups).sort(
(a, b) => a[1].order - b[1].order,
);
// 1-9 → индексы 0-8, 0 → индекс 9
const index = key === "0" ? 9 : parseInt(key) - 1;
if (index < groups.length) {
setCameraGroup(groups[index][0]);
return true;
}
return false;
},
);
// document title
useEffect(() => {