import { KeyboardEnum } from '../enums' ; export const addEscEnterKeyEffect = ( escKeyHandler , enterKeyHandler ) => { const handleKeyboard = ( event ) => { if ( event . keyCode === KeyboardEnum . Esc ) { escKeyHandler ( ) ; } if ( event . keyCode === KeyboardEnum . Enter ) { enterKeyHandler ( ) ; } } ; return getEventListenerEffect ( 'keyup' , handleKeyboard ) ; } ; export const getEventListenerEffect = ( eventName , handler ) => { window . addEventListener ( eventName , handler ) ; return ( ) => { window . removeEventListener ( eventName , handler ) ; } ; } ;