Skip to content

leonsilicon/inquirer-press-to-continue

Repository files navigation

inquirer-press-to-continue

npm version

Installation

Make sure you have inquirer installed:

npm install inquirer

Then, install inquirer-press-to-continue:

npm install inquirer-press-to-continue

Usage

import inquirer from 'inquirer';
import PressToContinuePrompt from 'inquirer-press-to-continue';
import type { KeyDescriptor } from 'inquirer-press-to-continue';

inquirer.registerPrompt('press-to-continue', PressToContinuePrompt);

const { key: enterKey } = await inquirer.prompt<{ key: KeyDescriptor }>({
  name: 'key',
  type: 'press-to-continue',
  enter: true,
});

console.log(enterKey.value); // "enter"

const { key: anyKey } = await inquirer.prompt<{ key: KeyDescriptor }>({
  name: 'key',
  type: 'press-to-continue',
  anyKey: true,
  pressToContinueMessage: 'Press a key to continue...',
});

console.log(anyKey.value);

API

key

Type: string

The key the user should press to continue.

anyKey

Type: boolean

Whether to allow the user to press any key to continue.

enter

Type: boolean

Only allow the enter key to be pressed.

pressToContinueMessage

Type: string

Custom message for prompting the user to press a key to continue.