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 11import mapKeys from 'lodash/mapKeys' ;
2+ import PropTypes from 'prop-types' ;
23import { useCallback , useEffect , useRef } from 'react' ;
34
45/**
@@ -29,7 +30,7 @@ export default function useKeyDownHandlers(keyHandlers) {
2930 */
3031 const handleEvent = useCallback ( ( e ) => {
3132 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 ;
3334 if ( e . shiftKey && isCtrl ) {
3435 handlers . current [ `ctrl-shift-${ e . key . toLowerCase ( ) } ` ] ?. ( e ) ;
3536 }
@@ -48,8 +49,13 @@ export default function useKeyDownHandlers(keyHandlers) {
4849
4950/**
5051 * Component version can be used in class components where hooks can't be used.
52+ *
53+ * @param {Record<string, (e: KeyboardEvent) => void> } handlers
5154 */
5255export const DocumentKeyDown = ( { handlers } ) => {
5356 useKeyDownHandlers ( handlers ) ;
5457 return null ;
5558} ;
59+ DocumentKeyDown . propTypes = {
60+ handlers : PropTypes . objectOf ( PropTypes . func )
61+ } ;
You can’t perform that action at this time.
0 commit comments