File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1
1
import mapKeys from 'lodash/mapKeys' ;
2
+ import PropTypes from 'prop-types' ;
2
3
import { useCallback , useEffect , useRef } from 'react' ;
3
4
4
5
/**
@@ -29,7 +30,7 @@ export default function useKeyDownHandlers(keyHandlers) {
29
30
*/
30
31
const handleEvent = useCallback ( ( e ) => {
31
32
const isMac = navigator . userAgent . toLowerCase ( ) . indexOf ( 'mac' ) !== - 1 ;
32
- const isCtrl = isMac ? e . metaKey && this . isMac : e . ctrlKey ;
33
+ const isCtrl = isMac ? e . metaKey : e . ctrlKey ;
33
34
if ( e . shiftKey && isCtrl ) {
34
35
handlers . current [ `ctrl-shift-${ e . key . toLowerCase ( ) } ` ] ?. ( e ) ;
35
36
}
@@ -48,8 +49,13 @@ export default function useKeyDownHandlers(keyHandlers) {
48
49
49
50
/**
50
51
* Component version can be used in class components where hooks can't be used.
52
+ *
53
+ * @param {Record<string, (e: KeyboardEvent) => void> } handlers
51
54
*/
52
55
export const DocumentKeyDown = ( { handlers } ) => {
53
56
useKeyDownHandlers ( handlers ) ;
54
57
return null ;
55
58
} ;
59
+ DocumentKeyDown . propTypes = {
60
+ handlers : PropTypes . objectOf ( PropTypes . func )
61
+ } ;
You can’t perform that action at this time.
0 commit comments