Skip to content

zewish/clikey

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

clikey

Prompts for a single keypress in a node.js CLI app

Usage

#!/usr/bin/env node
const clikey = require('clikey');

(async () => {
  const answer = await clikey('Are you sure? [y/N]');
  // answer received when a single key is pressed

  if (answer.toLowerCase() === 'y') {
    return console.log('You said YES!!!');
  }

  console.log('You said NO');
})();

Install

$ npm install --save clikey

Test

$ npm install && npm test