Q:

components key events gutenberg

import { KeyboardShortcuts } from '@wordpress/components';
import { withState } from '@wordpress/compose';
 
const MyKeyboardShortcuts = withState( {
    isAllSelected: false,
} )( ( { isAllSelected, setState } ) => { 
    const selectAll = () => {
        setState( { isAllSelected: true } )
    };
 
    return (
        <div>
            <KeyboardShortcuts shortcuts={ {
                'mod+a': selectAll,
            } } />
            [cmd/ctrl + A] Combination pressed? { isAllSelected ? 'Yes' : 'No' }
        </div>
    ) 
} )
0

New to Communities?

Join the community