JSPM

@wojtekmaj/predict-input-value

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 559
  • Score
    100M100P100Q114680F
  • License MIT

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

Package Exports

  • @wojtekmaj/predict-input-value

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@wojtekmaj/predict-input-value) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm downloads tested with jest

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) {
  const nextValue = predictInputValue(event); // "hi"
}

License

The MIT License.

Author

Wojciech Maj
kontakt@wojtekmaj.pl
http://wojtekmaj.pl