modem intro with keyboard handler

This commit is contained in:
2026-08-16 07:22:57 +02:00
parent 9aad7ad534
commit 9164d902df
+10 -1
View File
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useState, useEffect } from 'react';
import { playLine1Sequence, markConnected } from '../lib/sound';
type DialState = 'idle' | 'dialing';
export default function ModemIntro() {
@@ -8,6 +8,15 @@ export default function ModemIntro() {
setState('dialing');
playLine1Sequence(() => { markConnected(); window.location.href = '/bbs/'; });
}
useEffect(() => {
if (state !== 'idle') return;
function onKeyDown(e: KeyboardEvent) {
if (e.key === '1') { selectLine(1); }
if (e.key === '2') { selectLine(2); }
}
window.addEventListener('keydown', onKeyDown);
return () => window.removeEventListener('keydown', onKeyDown);
}, [state]);
return (
<div className="ansi-text welcome-modem" role="region" aria-label="Modem connect intro">
<pre style={{ textAlign: 'center' }}>{`+------------------------------------------+