A fun library that can be used to fake fast typing or create typing time-lapses.
Install via node.js or yarn
npm install typoist
# Or
yarn add typoist
Get the dist files from the releases page and include them in the html.
<script src="./path/to/typoist.min.js"></script>
All the exported members will be available under a global variable Typoist
, eg: Typoist.Typoist
. See the API Docs.
- Browser Example. See the code in the
gh-pages
branch. - Node.js CLI Example: Clone this repo and use locally.
Typoist exports the following:
Typoist
(class): The main class having the following properties.
-
constructor(settings)
: Where settings is an object with the following properties:{ /** The maximum typing speed in characters per second. */ speed?: number, // Default: 10 /** Probability of making a mistake. */ mistakeProbability?: number, // Default: 0.1 /** A function that is fired each time a character is to be appended to the output. */ appendFunction: (character: string) => void, // No default /** A function that is fired each time the last character in the final output is to be removed. */ deleteFunction: () => void, // No default /** A callback that is fired when typing is complete. */ onComplete?: () => void // No default }
-
setStringToType(string)
: This method is used to set the typing string. (and to change it later) -
startTyping()
: Start typing. -
stopTyping()
: Stop typing.NOTE: All methods are chainable.
TypoistDefaults
: An object containing all the default settings.
Example:
const { Typoist } = require('typoist');
const inputString = 'Hello World';
const outputString = '';
const typoist = new Typoist({
speed: 2,
mistakeProbability: 0.2,
appendFunction: (character) => outputString = outputString + character, // Add a character to the end
deleteFunction: () => outputString = outputString.slice(0, -1) // Remove a character from the end
})
Open Source by Harsh Khandeparkar