Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/cliffy/examples/keycode.ts

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Latest
File
#!/usr/bin/env -S deno run
import { KeyCode, parse } from "../keycode/mod.ts";
while (true) { const data = new Uint8Array(8);
Deno.stdin.setRaw(true); const nread = await Deno.stdin.read(data); Deno.stdin.setRaw(false);
if (nread === null) { break; }
const keys: Array<KeyCode> = parse(data.subarray(0, nread));
for (const key of keys) { if (key.ctrl && key.name === "c") { console.log("exit"); Deno.exit(); } console.log("Key pressed: %O", key); }}