Skip to content

Observable scanner for specified phrase in the keystroke event stream. Uses RxJS.

License

Notifications You must be signed in to change notification settings

aeldar/scan-keystroke-rx

Repository files navigation

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;

About

Observable scanner for specified phrase in the keystroke event stream. Uses RxJS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published