Predicts the input value during KeyDown or KeyPress events, before the input is actually changed
npm install @wojtekmaj/predict-input-value !downloads 
Predicts the input value during KeyDown or KeyPress events, before the input is actually changed.
- 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).
Conditions:
- Input: value "hello"
- Selected text: "ello"
- Key pressed: i
``ts``
function onKeyPress(event: React.KeyboardEvent
const nextValue = predictInputValue(event); // "hi"
}
The MIT License.
Wojciech Maj |