Skip to content

Commit

Permalink
πŸ”Œ (#9) - implemt space to play pause feature
Browse files Browse the repository at this point in the history
  • Loading branch information
KJG04 committed Jun 9, 2022
1 parent 1605364 commit 409c465
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/components/ContentController/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ const ContentController = () => {

const onSpaceDown = useCallback(
(e: KeyboardEvent) => {
if (
e.key === "Space" &&
!e.shiftKey &&
!e.ctrlKey &&
!e.metaKey &&
!e.altKey
) {
if (e.code === "Space") {
console.log("123");

e.stopPropagation();
e.preventDefault();

Expand All @@ -85,10 +81,10 @@ const ContentController = () => {

useEffect(() => {
if (!controlDisable) {
document.addEventListener("keypress", onSpaceDown);
window.addEventListener("keydown", onSpaceDown);

return () => {
document.removeEventListener("keypress", onSpaceDown);
window.removeEventListener("keydown", onSpaceDown);
};
}
}, [controlDisable, onSpaceDown]);
Expand Down

0 comments on commit 409c465

Please sign in to comment.