prettify, sorry for the big ass commit

This commit is contained in:
Olivier Gagnon
2021-09-04 19:09:30 -04:00
parent 3d7cdb4ef9
commit a18bdd6afc
554 changed files with 91615 additions and 66138 deletions
+16 -16
View File
@@ -1,24 +1,24 @@
import React, { useEffect } from 'react';
import React, { useEffect } from "react";
interface IProps {
onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
onFailure: (options?: { automated: boolean }) => void;
onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
onFailure: (options?: { automated: boolean }) => void;
}
export function KeyHandler(props: IProps): React.ReactElement {
let elem: any;
useEffect(() => elem.focus());
let elem: any;
useEffect(() => elem.focus());
function onKeyDown(event: React.KeyboardEvent<HTMLElement>): void {
console.log("isTrusted?", event.isTrusted)
if(!event.isTrusted) {
console.log("untrusted event!")
props.onFailure({ automated: true });
return;
}
props.onKeyDown(event);
function onKeyDown(event: React.KeyboardEvent<HTMLElement>): void {
console.log("isTrusted?", event.isTrusted);
if (!event.isTrusted) {
console.log("untrusted event!");
props.onFailure({ automated: true });
return;
}
props.onKeyDown(event);
}
// invisible autofocused element that eats all the keypress for the minigames.
return (<div tabIndex={1} ref={c => elem = c} onKeyDown={onKeyDown} />)
}
// invisible autofocused element that eats all the keypress for the minigames.
return <div tabIndex={1} ref={(c) => (elem = c)} onKeyDown={onKeyDown} />;
}