diff --git a/src/components/layout/Default.js b/src/components/layout/Default.js index a11652ab..e7286fa0 100644 --- a/src/components/layout/Default.js +++ b/src/components/layout/Default.js @@ -32,11 +32,15 @@ const Main = styled(GrowScroll).attrs({ type Props = { location: Location, + i18n: { + reloadResources: Function, + }, } class Default extends Component { componentDidMount() { window.requestAnimationFrame(() => (this._timeout = setTimeout(() => window.onAppReady(), 300))) + window.addEventListener('keydown', this.kbShortcut) } componentDidUpdate(prevProps) { @@ -54,6 +58,13 @@ class Default extends Component { componentWillUnmount() { clearTimeout(this._timeout) + window.removeEventListener('keydown', this.kbShortcut) // Prevents adding multiple listeners when hot reloading + } + + kbShortcut = event => { + if (event.ctrlKey && event.key === 'l') { + this.props.i18n.reloadResources() + } } _timeout = undefined