smooth-input

Library for imitate human input

Usage no npm install needed!

<script type="module">
  import smoothInput from 'https://cdn.skypack.dev/smooth-input';
</script>

README

smooth-input

Library for imitate human input

Installation

npm i smooth-input

Simple example

Demo Animation

import {SmoothInput} from 'smooth-input';
const h1 = document.getElementById('title')
const si = new SmoothInput(h1, {
    symbolsPerSecond: 10,
    delay: 5000,
    symbolsDelay: {' ': 500},
    text: 'Hello, World!'
})

Initialization

import {SmoothInput} from 'smooth-input';
const si = new SmoothInput(htmlElement, {...})

If you want to use default carriage you have to import css:

import 'smooth-input/css/style.css'

And set special class to text container:

smooth-text-container

Options

Name Type Default Description
symbolsPerSecond number 10 Count of symbols per second
delay number 0 Time before start
symbolsDelay Object {} Delay for certain symbols
text string or null null Content of target element. If there isn't take textContent of element
carriage CarriageOptions - Config for default carriage
CarriageOptions
Name Type Default Description
visible boolean true Visibility of carriage
hideAfterInput boolean true Hide carriage after all text input
hideDelay boolean true Time before hide carriage after input

Methods

Methods of SmoothInput instance


setText(text: string): void

Removing old text and start input new one

Parameters:

Name Type Description
text string -

Returns: void


addTextToEnd(text: string): void

Adding text to enter at the end

Parameters:

Name Type Description
text string -

Returns: void