@teaui/core
Version:
A high-level terminal UI library for Node
31 lines • 833 B
JavaScript
import { Container } from '../Container.js';
/**
* A non-visual, non-focusable container that receives key events as a fallback —
* only when no hotkey matches and no child view has focus. If multiple Keyboard
* views are nested, the innermost one receives the event.
*/
export class Keyboard extends Container {
#onKey;
constructor(props) {
super(props);
this.#update(props);
}
update(props) {
this.#update(props);
super.update(props);
}
#update({ onKey }) {
this.#onKey = onKey;
}
naturalSize(available) {
return super.naturalSize(available);
}
receiveKey(event) {
this.#onKey?.(event);
}
render(viewport) {
viewport.registerKeyboard();
super.render(viewport);
}
}
//# sourceMappingURL=Keyboard.js.map