Vize

on-start-typing

Whether a keyboard event would type a printable character.

Package @vizejs/composable/on-start-typing
Own the source vize lib pull composable:on-start-typing
Runtime exports isTypingKeystroke, onStartTyping
Gzip budget 1536 B

Usage

import { isTypingKeystroke, onStartTyping } from "@vizejs/composable/on-start-typing";

Runtime contract

Utility Category Stability SSR Hydration Cleanup Targets Host globals Uses
isTypingKeystroke input experimental safe not-applicable none web, server, worker, native, desktop, terminal — —
onStartTyping input experimental deterministic-fallback stable caller, reactive-scope web, desktop document isTypingKeystroke, tryOnScopeDispose

API

isTypingKeystroke

Whether a keyboard event would type a printable character. Single-character keys (letters, digits, punctuation; not space) without ctrl/meta/alt qualify.

function isTypingKeystroke(event: KeyboardEvent): boolean

onStartTyping

Call a handler when the user starts typing while no editable element has focus — typically to focus a search field. Editable means input, textarea, select, or any element with isContentEditable, and elements with role="textbox"/"searchbox"/"combobox". Nothing is registered during server rendering; the listener is removed with the owning scope or the returned stop function.

function onStartTyping( handler: (event: KeyboardEvent) => void, options: OnStartTypingOptions = {}, ): () => void

Types

StartTypingHost

Document-like capability observed by onStartTyping.

Member Type Description
activeElement Element | null Currently focused element.

OnStartTypingOptions

Options for onStartTyping.

Member Type Description
host? MaybeRefOrGetter<StartTypingHost | null | undefined> Reactive document capability for alternate runtimes and tests.