import React, { useEffect } from 'react'; interface IProps { onKeyDown: (event: React.KeyboardEvent) => void; } export function KeyHandler(props: IProps): React.ReactElement { let elem: any; useEffect(() => elem.focus()); function onKeyDown(event: React.KeyboardEvent): void { if(!event.isTrusted) return; props.onKeyDown(event); } // invisible autofocused element that eats all the keypress for the minigames. return (
elem = c} onKeyDown={onKeyDown} />) }