mirror of
https://github.com/p-stream/p-stream.git
synced 2026-03-11 17:55:33 +00:00
esc now closes the caption preview
This commit is contained in:
parent
665d06c8e0
commit
c6873907ef
1 changed files with 17 additions and 0 deletions
|
|
@ -28,6 +28,23 @@ export function CaptionPreview(props: {
|
|||
onToggle: () => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { fullscreen, show, onToggle } = props;
|
||||
|
||||
useEffect(() => {
|
||||
if (!fullscreen || !show) return;
|
||||
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") {
|
||||
onToggle();
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, [fullscreen, show, onToggle]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames({
|
||||
|
|
|
|||
Loading…
Reference in a new issue