fix: shortcut key conflicts with input (#212)

* fix: shortcut key conflicts with input

* Update src/lib/components/VideoPreview.svelte

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
This commit is contained in:
Xinrea
2025-11-01 20:44:27 +08:00
committed by GitHub
parent 588559c645
commit e7d8c8814d

View File

@@ -809,8 +809,16 @@
function handleKeydown(event: KeyboardEvent) {
if (!show || !isVideoLoaded) return;
// 如果在输入框中,不处理某些快捷键
const isInInput = (event.target as HTMLElement)?.tagName === "INPUT";
const target = event.target as HTMLElement | null;
const tagName = target?.tagName;
// 如果当前焦点位于可编辑元素内,则跳过快捷键处理
const isInInput =
(!!tagName && ["INPUT", "TEXTAREA", "SELECT"].includes(tagName)) ||
!!target?.isContentEditable ||
!!target?.closest(
"input, textarea, select, [contenteditable='true'], [data-hotkey-block]"
);
switch (event.key) {
case "【":