export const keys = {
    Space: 'Space',
    Escape: 'Escape'
};
export const useKeyNavigation = ({ opened, closeOnEsc, onToggle })=>{
    const onKeyDown = (event)=>{
        switch(event.code){
            case keys.Space:
                {
                    if (!opened) {
                        event.preventDefault();
                        onToggle(true, event);
                    }
                    break;
                }
            case keys.Escape:
                {
                    if (opened && closeOnEsc) {
                        event.preventDefault();
                        onToggle(false, event);
                    }
                    break;
                }
            default:
                {
                    break;
                }
        }
    };
    return {
        onKeyDown
    };
};
