types-keyboardevent
v0.0.0
Published
TypeScript types for the KeyboardEvent code and key values.
Maintainers
Readme
types-keyboardevent
types-keyboardevent provides TypeScript types for KeyboardEvent,
generated directly from W3C UI Events KeyboardEvent specifications.
npm install types-keyboardeventKeyboardEventCoderepresents a union of knownevent.codevalues.KeyboardEventKeyrepresents a union of knownevent.keyvalues.- Includes sub-types such as
KeyboardEventCode.NumpadandKeyboardEventKey.Navigation. - Source is generated directly from:
- https://w3c.github.io/uievents-code/
- https://w3c.github.io/uievents-key/
This package is type-only at runtime. Its JavaScript entrypoints intentionally export no values.
Usage
import type { KeyboardEventCode, KeyboardEventKey } from "types-keyboardevent";
const isMovementCode = (code: KeyboardEventCode.Arrowpad) => code === "ArrowLeft" || code === "ArrowRight";
const isConfirmKey = (key: KeyboardEventKey) => key === "Enter" || key === " ";You can also import the type families directly from their subpaths:
import type { KeyboardEventCode } from "types-keyboardevent/KeyboardEventCode";
import type { KeyboardEventKey } from "types-keyboardevent/KeyboardEventKey";API surface
KeyboardEventCode
Includes values such as "KeyA", "ArrowRight", "NumpadEnter", and media-related codes.
Useful namespaces include:
KeyboardEventCode.ModifierKeyboardEventCode.ArrowpadKeyboardEventCode.NumpadKeyboardEventCode.FunctionKeyboardEventCode.Media
KeyboardEventKey
Includes values such as "Enter", "ArrowRight", "AudioVolumeUp", and "MediaPlayPause".
Useful namespaces include:
KeyboardEventKey.ModifierKeyboardEventKey.NavigationKeyboardEventKey.EditingKeyboardEventKey.MultimediaKeyboardEventKey.AudioKeyboardEventKey.Browser
