UNPKG

@airplane/views

Version:

A React library for building Airplane views. Views components are optimized in style and functionality to produce internal apps that are easy to build and maintain.

22 lines (21 loc) 766 B
export type KeyPressProps = { /** * A key, list of keys, or list of key combinations that should be listened to. * e.g. "ENTER", ["ENTER", "TAB"], [["SHIFT", "ENTER"], "TAB"] */ targetKeys: KeyboardEvent["key"] | Array<KeyboardEvent["key"] | KeyboardEvent["key"][]>; /** * If true, key events will be listened to from the window. * If false, you need to manually call upHandler and downHandler and have more control over event handling. */ listenToWindow?: boolean; }; export default function useKeyPress({ targetKeys, listenToWindow, }: KeyPressProps): { keyPressed: boolean; upHandler: ({ key }: { key: string; }) => boolean; downHandler: ({ key }: { key: string; }) => boolean; };