import * as React from "react" ; import { Callback } from "polar-shared/src/util/Functions" ; import { GlobalHotKeys } from "react-hotkeys" ; import { deepMemo } from "../../react/ReactUtils" ; const globalKeyMap = { ESCAPE : [ 'Escape' ] , } ; interface IProps { readonly onEscape : Callback ; readonly children : JSX . Element ; } param props constructor export const InputEscapeListener = deepMemo ( function InputEscapeListener ( props ) { const handleKeyDown = ( event ) => { if ( event . key === 'Escape' ) { props . onEscape ( ) ; event . stopPropagation ( ) ; event . preventDefault ( ) ; return ; } } ; const handlers = { ESCAPE : ( ) => props . onEscape ( ) } ; return ( < div onKeyDown = { handleKeyDown } > < GlobalHotKeys allowChanges keyMap = { globalKeyMap } handlers = { handlers } / > { props . children } < /div>); } ) ;