disables page scroll when pressing spacebar

This commit is contained in:
Cassidy 2020-05-17 18:30:20 +07:00 committed by Sean Yesmunt
parent 8b68932997
commit b5f3ac0526

View file

@ -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);