mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-21 08:22:19 +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;
|
onToggle: () => void;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
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 (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames({
|
className={classNames({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue