@@ -47,12 +47,26 @@ export default function () {
4747 } , [ ] ) ;
4848
4949 // keyboard shortcut for run and build
50- const handleKeyPress = useCallback ( ( event : { repeat : any ; ctrlKey : boolean ; key : string ; } ) => {
51- if ( ! event . repeat && event . ctrlKey === true && event . key === "b" )
52- setShowPopup ( ! showPopup ) ;
53- callRunTaskApi ( ) ;
54- } , [ ] ) ;
55-
50+ const handleKeyPress = useCallback (
51+ ( event : KeyboardEvent ) => {
52+ const { repeat, ctrlKey, key, metaKey } = event ;
53+ if ( ! repeat && ctrlKey === true && key === "b" ) {
54+ setShowPopup ( ! showPopup ) ;
55+ callRunTaskApi ( ) ;
56+ }
57+
58+ if ( window . navigator && window . navigator . userAgent ) {
59+ if ( window . navigator . userAgent . indexOf ( "Mac" ) ) {
60+ if ( ! repeat && metaKey === true && key === "b" ) {
61+ setShowPopup ( ! showPopup ) ;
62+ callRunTaskApi ( ) ;
63+ }
64+ }
65+ }
66+ } ,
67+ [ callRunTaskApi , showPopup ]
68+ ) ;
69+
5670 // open http://localhost:4005
5771 const devWindow = useRef < Window | null > ( null ) ;
5872 useEffect ( ( ) => {
@@ -61,11 +75,11 @@ export default function () {
6175 devWindow . current = window . open ( "http://localhost:4005" , "_blank" ) ;
6276 window . focus ( ) ;
6377 }
64- document . addEventListener ( ' keydown' , handleKeyPress ) ;
78+ document . addEventListener ( " keydown" , handleKeyPress ) ;
6579 return ( ) => {
66- document . removeEventListener ( ' keydown' , handleKeyPress ) ;
80+ document . removeEventListener ( " keydown" , handleKeyPress ) ;
6781 } ;
68- } , [ status , handleKeyPress ] ) ;
82+ } , [ status , handleKeyPress ] ) ;
6983 return (
7084 < >
7185 < Menu name = "PublishMenu" order = { 1 } >
0 commit comments