mirror of
https://github.com/skoelle/28k8-moonweb-org.git
synced 2026-09-17 18:30:24 +00:00
initial commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { useEffect } from 'react';
|
||||
import { findKeyEntry } from '../lib/keymap';
|
||||
import { resetConnected } from '../lib/sound';
|
||||
export default function TerminalShell({ children }: { children?: React.ReactNode }) {
|
||||
useEffect(() => {
|
||||
function onKeyDown(e: KeyboardEvent) {
|
||||
if (e.metaKey || e.ctrlKey || e.altKey) return;
|
||||
const entry = findKeyEntry(e.key);
|
||||
if (!entry) return;
|
||||
if (entry.href === 'back') { window.history.back(); return; }
|
||||
if (entry.href === 'disconnect') { resetConnected(); window.location.href = '/'; return; }
|
||||
window.location.href = entry.href;
|
||||
}
|
||||
window.addEventListener('keydown', onKeyDown);
|
||||
return () => window.removeEventListener('keydown', onKeyDown);
|
||||
}, []);
|
||||
return <>{children}</>;
|
||||
}
|
||||
Reference in New Issue
Block a user