@types/react-key-handler
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

Installation

npm install --save @types/react-key-handler

Summary

This package contains type definitions for react-key-handler (https://github.com/ayrton/react-key-handler).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-key-handler.

index.d.ts

import * as React from "react";

type _KEYDOWN = "keydown";
type _KEYPRESS = "keypress";
type _KEYUP = "keyup";

export type Matcher = (event: KeyboardEvent, ref: ReactKeyHandlerIntrinsicProps) => boolean;

interface ReactKeyHandlerIntrinsicProps {
    /**
     * Any given [KeyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
     */
    keyValue?: string | string[];

    /**
     *  Any given [KeyboardEvent.keyCode](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode)
     *  @deprecated Deprecated in favour of `code`
     */
    keyCode?: number | number[];

    /**
     *  Any given [KeyboardEvent.code](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
     */
    code?: string | string[];

    /**
     *  Keyboard event type to listen to.
     *  @default 'keyup'
     */
    keyEventName?: _KEYDOWN | _KEYPRESS | _KEYUP;
}

export interface ReactKeyHandlerProps extends ReactKeyHandlerIntrinsicProps {
    /**
     * Callback that is called when they key is handled
     * @param event The event object
     */
    onKeyHandle: (event: React.KeyboardEvent) => void;
}

export default function KeyHandler(props: ReactKeyHandlerProps): React.JSX.Element;

export function keyHandleDecorator(
    matcher?: Matcher,
): (props: ReactKeyHandlerProps) => (Component: React.JSX.Element) => (...args: any[]) => React.JSX.Element;

export function keyToggleHandler(
    props: ReactKeyHandlerIntrinsicProps,
): (Component: React.JSX.Element) => (...args: any[]) => React.JSX.Element;

export function keyHandler(
    props: ReactKeyHandlerIntrinsicProps,
): (Component: React.JSX.Element) => (...args: any[]) => React.JSX.Element;

export const KEYDOWN: _KEYDOWN;

export const KEYPRESS: _KEYPRESS;

export const KEYUP: _KEYUP;

// Shut off automatic exporting
export {};

Additional Details

  • Last updated: Tue, 05 Dec 2023 16:38:07 GMT
  • Dependencies: @types/react

Credits

These definitions were written by Pedro Queiroz.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/react-key-handler

Weekly Downloads

1,565

Version

1.2.4

License

MIT

Unpacked Size

6.39 kB

Total Files

5

Last publish

Collaborators

  • types