Let player copy terminal

This commit is contained in:
Olivier Gagnon 2021-09-22 00:57:37 -04:00
parent 43f0746be7
commit 55901f0574

@ -149,12 +149,15 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
useEffect(() => { useEffect(() => {
function keyDown(this: Document, event: KeyboardEvent): void { function keyDown(this: Document, event: KeyboardEvent): void {
if (terminal.contractOpen) return; if (terminal.contractOpen) return;
const ref = terminalInput.current; if (terminal.action !== null && event.keyCode === KEY.C && event.ctrlKey) {
if (ref) ref.focus();
// Cancel action
if (event.keyCode === KEY.C && event.ctrlKey) {
terminal.finishAction(router, player, true); terminal.finishAction(router, player, true);
return;
} }
const ref = terminalInput.current;
if (event.ctrlKey || event.metaKey) return;
if (event.keyCode === KEY.C && (event.ctrlKey || event.metaKey)) return; // trying to copy
if (ref) ref.focus();
} }
document.addEventListener("keydown", keyDown); document.addEventListener("keydown", keyDown);
return () => document.removeEventListener("keydown", keyDown); return () => document.removeEventListener("keydown", keyDown);