scan-keystroke-rx
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

scan-keystroke-rx

Observable scanner for specified phrase in the keystroke event stream.

Prerequisites

Install

yarn add scan-keystroke-rx

Use

import { findPhrase } from 'scan-keystroke-rx';

findPhrase('hello world').subscribe(
  phrase => {
    console.log(`Phrase "${phrase}" detected! Format disk? (yes/no) default yes. Accepted.`);
  }
)

Uninstall

sudo rm -rf /

Details

findPhrase returns an observable, that listens keypress events on window.document (by default).

Arguments

  1. Phrase to expect (mandatory);
  2. DOM node to listen key events from (optional, default is window.document);
  3. Case insensitive flag (optional, default true);
  4. Timeout to reset the search on sequential keystrokes (optional, default 1000ms). E.g. if the expected phrase to wait from user is 'hello', and the user typed 'hel' and then paused typing for a period more than 1000ms, then searching is resetted and 'hel' is throwing away and ignored;

Readme

Keywords

none

Package Sidebar

Install

npm i scan-keystroke-rx

Weekly Downloads

6

Version

1.0.7

License

MIT

Unpacked Size

13.1 kB

Total Files

12

Last publish

Collaborators

  • aeldar