Use number keys on keyboard to move ptz camera to presets (#14278)

* Use number keys on keyboard to move ptz camera to presets

* clean up
This commit is contained in:
Josh Hawkins 2024-10-11 08:05:28 -05:00 committed by GitHub
parent ae91fa6a39
commit 748087483c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -531,9 +531,37 @@ function PtzControlPanel({
);
useKeyboardListener(
["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "+", "-"],
[
"ArrowLeft",
"ArrowRight",
"ArrowUp",
"ArrowDown",
"+",
"-",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
],
(key, modifiers) => {
if (modifiers.repeat) {
if (modifiers.repeat || !key) {
return;
}
if (["1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(key)) {
const presetNumber = parseInt(key);
if (
ptz &&
(ptz.presets?.length ?? 0) > 0 &&
presetNumber <= ptz.presets.length
) {
sendPtz(`preset_${ptz.presets[presetNumber - 1]}`);
}
return;
}