InputEvents
The InputEvents type maps event names to their callback signatures for the Input component. Use them with the .on() method to react to user interaction.
Type Definition
submit: Fired when the user presses Enter. Receives the finalstringvalue.change: Fired on every keystroke. Receives the currentstringvalue.exit: Fired when the user presses Escape. No arguments.
type InputEvents = {
submit: [value: string];
change: [value: string];
exit: [];
}
Usage
import { Input } from "ts-better-console";
const input = new Input();
input.on("change", (value) => {console.log("Typing:", value);});
input.on("submit", (value) => {console.log("Submitted:", value);});
input.on("exit", () => {console.log("Cancelled");});
Want to support this project?
If you find ts-better-console useful and want to support its development, consider starring the GitHub repository or buying me a coffee! Your support helps me dedicate more time to improving the library and adding new features.
Want to contribute to this project?
Contributions are welcome! If you're interested in improving the library, fixing bugs, or adding new features, feel free to check out the GitHub repository and submit a pull request. Whether you're a seasoned developer or new to open source, your contributions can make a difference!