UNPKG

@instawork/design-system

Version:

The design system for Instawork's web apps

34 lines (33 loc) 1.19 kB
/** * An enum of key names to their expected value from {@link KeyboardEvent.key}. * @type {Object.<string, string>} */ import { JQueryKeyboardEvent } from './jquery-events'; export declare enum KeyboardKey { arrowDown = "ArrowDown", arrowLeft = "ArrowLeft", arrowRight = "ArrowRight", arrowUp = "ArrowUp" } /** * A map of non-standard keyboard key names used by IE to the standard key names. * @type {Object.<string, string>} */ export declare const COMPAT_MAP: { [key: string]: string; }; /** * Utility class for dealing with browser compatibility issues related to keyboard input */ export declare class KeyboardInput { static fromEvent(e: JQueryKeyboardEvent): string; /** * Used to wrap a keyboard event handler so that {KeyboardEvent.key} uses the standard value. * * This can be used to avoid having to check for multiple values to facilitate IE compatibility. * * JQuery Example: * $('selector').on('keydown', KeyboardInput.wrapEvent(function (e) { return e.key === 'ArrowUp'; }); */ static wrapEvent<TEvent extends JQueryKeyboardEvent, TReturn>(handler: (e: TEvent) => TReturn): (e: TEvent) => TReturn; }