Skip to main content
Module

x/cliffy/examples/keypress.ts

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Go to Latest
File
#!/usr/bin/env -S deno run --unstable
import { keypress, KeyPressEvent,} from "https://deno.land/x/cliffy@v0.20.1/keypress/mod.ts";
/** Promise */const event: KeyPressEvent = await keypress();console.log("Key pressed: %s", event.key);
/** AsyncIterator */for await (const event: KeyPressEvent of keypress()) { console.log("Key pressed: %s", event.key); if (event.ctrlKey && event.key === "c") { console.log("exit"); break; }}
/** EventTarget */keypress().addEventListener("keydown", (event: KeyPressEvent) => { console.log("Key pressed: %s", event.key); if (event.ctrlKey && event.key === "c") { console.log("exit"); keypress().dispose(); }});