mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +01:00
Fix keyboard event handling in KeyboardEvents component
- Changed the condition from 'k' to 'keyL' for 'j', 'l', 'm', 'f', 'c', 'r' keys to handle uppercase keys properly. - Fixed the condition for toggling play/pause to work with both ' ' and 'k' keys. This commit addresses issues with keyboard event handling and ensures proper functionality with both uppercase and lowercase keys.
This commit is contained in:
parent
892292088d
commit
2722a7db96
1 changed files with 9 additions and 8 deletions
|
@ -71,9 +71,10 @@ export function KeyboardEvents() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const k = evt.key;
|
const k = evt.key;
|
||||||
|
const keyL = evt.key.toLowerCase();
|
||||||
|
|
||||||
// Volume
|
// Volume
|
||||||
if (["ArrowUp", "ArrowDown", "m"].includes(k)) {
|
if (["ArrowUp", "ArrowDown", "m", "M"].includes(k)) {
|
||||||
dataRef.current.setShowVolume(true);
|
dataRef.current.setShowVolume(true);
|
||||||
|
|
||||||
if (volumeDebounce.current) clearTimeout(volumeDebounce.current);
|
if (volumeDebounce.current) clearTimeout(volumeDebounce.current);
|
||||||
|
@ -89,7 +90,7 @@ export function KeyboardEvents() {
|
||||||
dataRef.current.setVolume(
|
dataRef.current.setVolume(
|
||||||
(dataRef.current.mediaPlaying?.volume || 0) - 0.15,
|
(dataRef.current.mediaPlaying?.volume || 0) - 0.15,
|
||||||
);
|
);
|
||||||
if (k === "m") dataRef.current.toggleMute();
|
if (keyL === "m") dataRef.current.toggleMute();
|
||||||
|
|
||||||
// Video playback speed
|
// Video playback speed
|
||||||
if (k === ">" || k === "<") {
|
if (k === ">" || k === "<") {
|
||||||
|
@ -106,9 +107,9 @@ export function KeyboardEvents() {
|
||||||
dataRef.current.display?.setTime(dataRef.current.time + 5);
|
dataRef.current.display?.setTime(dataRef.current.time + 5);
|
||||||
if (k === "ArrowLeft")
|
if (k === "ArrowLeft")
|
||||||
dataRef.current.display?.setTime(dataRef.current.time - 5);
|
dataRef.current.display?.setTime(dataRef.current.time - 5);
|
||||||
if (k === "j")
|
if (keyL === "j")
|
||||||
dataRef.current.display?.setTime(dataRef.current.time - 10);
|
dataRef.current.display?.setTime(dataRef.current.time - 10);
|
||||||
if (k === "l")
|
if (keyL === "l")
|
||||||
dataRef.current.display?.setTime(dataRef.current.time + 10);
|
dataRef.current.display?.setTime(dataRef.current.time + 10);
|
||||||
if (k === "." && dataRef.current.mediaPlaying?.isPaused)
|
if (k === "." && dataRef.current.mediaPlaying?.isPaused)
|
||||||
dataRef.current.display?.setTime(dataRef.current.time + 1);
|
dataRef.current.display?.setTime(dataRef.current.time + 1);
|
||||||
|
@ -116,18 +117,18 @@ export function KeyboardEvents() {
|
||||||
dataRef.current.display?.setTime(dataRef.current.time - 1);
|
dataRef.current.display?.setTime(dataRef.current.time - 1);
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
if (k === "f") dataRef.current.display?.toggleFullscreen();
|
if (keyL === "f") dataRef.current.display?.toggleFullscreen();
|
||||||
if (k === " ")
|
if (k === " " || keyL === "k")
|
||||||
dataRef.current.display?.[
|
dataRef.current.display?.[
|
||||||
dataRef.current.mediaPlaying.isPaused ? "play" : "pause"
|
dataRef.current.mediaPlaying.isPaused ? "play" : "pause"
|
||||||
]();
|
]();
|
||||||
if (k === "Escape") dataRef.current.router.close();
|
if (k === "Escape") dataRef.current.router.close();
|
||||||
|
|
||||||
// captions
|
// captions
|
||||||
if (k === "c") dataRef.current.toggleLastUsed().catch(() => {}); // ignore errors
|
if (keyL === "c") dataRef.current.toggleLastUsed().catch(() => {}); // ignore errors
|
||||||
|
|
||||||
// Do a barrell roll!
|
// Do a barrell roll!
|
||||||
if (k === "r") {
|
if (keyL === "r") {
|
||||||
if (dataRef.current.isRolling || evt.ctrlKey || evt.metaKey) return;
|
if (dataRef.current.isRolling || evt.ctrlKey || evt.metaKey) return;
|
||||||
|
|
||||||
dataRef.current.setIsRolling(true);
|
dataRef.current.setIsRolling(true);
|
||||||
|
|
Loading…
Reference in a new issue