From b5f3ac0526a7a86aaf19da6529a1c09b425a3f97 Mon Sep 17 00:00:00 2001 From: Cassidy Date: Sun, 17 May 2020 18:30:20 +0700 Subject: [PATCH] disables page scroll when pressing spacebar --- ui/component/app/view.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ui/component/app/view.jsx b/ui/component/app/view.jsx index 5c834d2e8..39f3ff860 100644 --- a/ui/component/app/view.jsx +++ b/ui/component/app/view.jsx @@ -161,6 +161,17 @@ function App(props: Props) { return () => window.removeEventListener('mouseup', handleForwardAndBackButtons); }); + // allows user to pause miniplayer using the spacebar without the page scrolling down + useEffect(() => { + const handleKeyPress = e => { + if (e.key === ' ' && e.target === document.body) { + e.preventDefault(); + } + }; + window.addEventListener('keydown', handleKeyPress); + return () => window.removeEventListener('keydown', handleKeyPress); + }); + useEffect(() => { if (referredRewardAvailable && sanitizedReferrerParam && isRewardApproved) { setReferrer(sanitizedReferrerParam, true);