@wojtekmaj/predict-input-value
TypeScript icon, indicating that this package has built-in type declarations

1.3.2 • Public • Published

npm downloads CI

Predict-Input-Value

Predicts the input value during KeyDown or KeyPress events, before the input is actually changed.

tl;dr

  • Install by executing npm install @wojtekmaj/predict-input-value or yarn add @wojtekmaj/predict-input-value.
  • Import by adding import predictInputValue from '@wojtekmaj/predict-input-value'.
  • Use it by writing const nextValue = predictInputValue(event).

Example

Conditions:

  • Input: value "hello"
  • Selected text: "ello"
  • Key pressed: i
function onKeyPress(event: React.KeyboardEvent<HTMLInputElement>): void {
  const nextValue = predictInputValue(event); // "hi"
}

License

The MIT License.

Author

Wojciech Maj Wojciech Maj

Readme

Keywords

Package Sidebar

Install

npm i @wojtekmaj/predict-input-value

Weekly Downloads

938

Version

1.3.2

License

MIT

Unpacked Size

15.6 kB

Total Files

10

Last publish

Collaborators

  • wojtekmaj