Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/node/_readline.d.ts>Key

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
interface Key
import { type Key } from "https://deno.land/std@0.137.0/node/_readline.d.ts";

The readline module provides an interface for reading data from a Readable stream (such as process.stdin) one line at a time. It can be accessed using:

const readline = require('readline');

The following simple example illustrates the basic use of the readline module.

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.question('What do you think of Node.js? ', (answer) => {
  // TODO: Log the answer in a database
  console.log(`Thank you for your valuable feedback: ${answer}`);

  rl.close();
});

Once this code is invoked, the Node.js application will not terminate until thereadline.Interface is closed because the interface waits for data to be received on the input stream.

Properties

optional
sequence: string | undefined
optional
name: string | undefined
optional
ctrl: boolean | undefined
optional
meta: boolean | undefined
optional
shift: boolean | undefined