fn
readInputState
v0.0.5Reads the value and current selection of an <input>/<textarea>
into a plain InputState. A null selection (some input types report it)
falls back to a collapsed caret at the end of the value.
Example
ts
const { value, selection } = readInputState(inputEl);Signature
ts
declare function readInputState(element: TextFieldElement): InputState;Parameters
| Parameter | Type | Description |
|---|---|---|
element | TextFieldElement | The input or textarea to read |
Returns
InputStateThe element's { value, selection }| Property | Type | Description |
|---|---|---|
value | string | The element's current value. |
selection | readonly [from: number, to: number] | The selection as [from, to] (collapsed caret when from === to). |