-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/iosifnicolae2/radio-crest…
- Loading branch information
Showing
8 changed files
with
792 additions
and
810 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {useEffect} from 'react'; | ||
|
||
const useSpaceBarPress = (callback: () => void) => { | ||
useEffect(() => { | ||
const handleKeyDown = (e: any) => { | ||
const isInputOrTextArea = ['input', 'textarea', 'select'].includes( | ||
e.target.tagName.toLowerCase(), | ||
); | ||
|
||
if ( | ||
e.keyCode === 32 && | ||
e.target.getAttribute('contentEditable') !== 'true' && | ||
!isInputOrTextArea | ||
) { | ||
e.preventDefault(); | ||
} | ||
}; | ||
|
||
const handleKeyPress = (e: any) => { | ||
const isInputOrTextArea = ['input', 'textarea', 'select'].includes( | ||
e.target.tagName.toLowerCase(), | ||
); | ||
|
||
if ( | ||
(e.key === ' ' || e.code === 'Space' || e.keyCode === 32) && | ||
!isInputOrTextArea | ||
) { | ||
callback(); | ||
} | ||
}; | ||
|
||
document.body.addEventListener('keyup', handleKeyPress); | ||
document.body.addEventListener('keydown', handleKeyDown); | ||
|
||
return () => { | ||
document.body.removeEventListener('keyup', handleKeyPress); | ||
document.body.removeEventListener('keydown', handleKeyDown); | ||
}; | ||
}, [callback]); | ||
}; | ||
|
||
export default useSpaceBarPress; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
b98a52a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
radio-crestin-com-gjii – ./
radio-crestin-com-gjii-git-master-iosifnicolae2v1.vercel.app
radio-crestin-com-gjii.vercel.app
radio-crestin-com-gjii-iosifnicolae2v1.vercel.app