diff --git a/app/assets/javascripts/components/components/lightbox.jsx b/app/assets/javascripts/components/components/lightbox.jsx index 36f078a3a03caa8eff81c93817418754b1b01f07..29822ccb34035c34b908367c741054c71b931848 100644 --- a/app/assets/javascripts/components/components/lightbox.jsx +++ b/app/assets/javascripts/components/components/lightbox.jsx @@ -40,6 +40,18 @@ const Lightbox = React.createClass({ mixins: [PureRenderMixin], + componentDidMount () { + this._listener = window.addEventListener('keyup', e => { + if (e.key === 'Escape') { + this.props.onCloseClicked(); + } + }); + }, + + componentWillUnmount () { + window.removeEventListener(this._listener); + }, + render () { const { intl, isVisible, onOverlayClicked, onCloseClicked, children } = this.props;