mirror of
https://github.com/skoelle/28k8-moonweb-org.git
synced 2026-09-17 18:30:24 +00:00
modem intro with keyboard handler
This commit is contained in:
@@ -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' }}>{`+------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user