@acusti/use-keyboard-events
Version:
React hook that takes keyboard event handlers and attaches them to the document
33 lines (31 loc) • 1.03 kB
Flow
/**
* Flowtype definitions for handlers
* Generated by Flowgen from a Typescript Definition
* Flowgen v1.21.0
* @flow
*/
export type EventType = "keydown" | "keypress" | "keyup";
export type Handler = (event: KeyboardEvent) => mixed;
declare type HandlerConfig = {|
ignoreUsedKeyboardEvents: boolean,
priority: number,
|};
declare type HandlersByPriority = Array<Set<Handler>>;
declare export var handlersData: {|
config: Map<Handler, HandlerConfig>,
keydown: HandlersByPriority,
keypress: HandlersByPriority,
keyup: HandlersByPriority,
|};
declare export function addHandler(x: {|
eventType: EventType,
handler: Handler | void,
ignoreUsedKeyboardEvents?: boolean,
priority?: number,
|}): () => void;
declare export function isPrimaryModifierPressed(event: KeyboardEvent): boolean;
declare export var usesKeyEvents: (target: EventTarget) => boolean;
declare export var isEventTargetUsingKeyEvent: (
event: KeyboardEvent
) => boolean;
declare export function addHandlers(doc: Document): (() => void) | void;