Skip to content

jsxtools/types-keyboardevent

Repository files navigation

types-keyboardevent

types-keyboardevent provides TypeScript types for KeyboardEvent, generated directly from W3C UI Events KeyboardEvent specifications.

npm install types-keyboardevent

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.Modifier
  • KeyboardEventCode.Arrowpad
  • KeyboardEventCode.Numpad
  • KeyboardEventCode.Function
  • KeyboardEventCode.Media

KeyboardEventKey

Includes values such as "Enter", "ArrowRight", "AudioVolumeUp", and "MediaPlayPause".

Useful namespaces include:

  • KeyboardEventKey.Modifier
  • KeyboardEventKey.Navigation
  • KeyboardEventKey.Editing
  • KeyboardEventKey.Multimedia
  • KeyboardEventKey.Audio
  • KeyboardEventKey.Browser

License

MIT-0

About

TypeScript types for the KeyboardEvent code and key values.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors