1 | import { getNextKeyDef } from './getNextKeyDef';
|
2 | /**
|
3 | * @internal Do not create/alter this by yourself as this type might be subject to changes.
|
4 | */
|
5 | export declare type keyboardState = {
|
6 | /**
|
7 | All keys that have been pressed and not been lifted up yet.
|
8 | */
|
9 | pressed: {
|
10 | keyDef: keyboardKey;
|
11 | unpreventedDefault: boolean;
|
12 | }[];
|
13 | /**
|
14 | Active modifiers
|
15 | */
|
16 | modifiers: {
|
17 | alt: boolean;
|
18 | caps: boolean;
|
19 | ctrl: boolean;
|
20 | meta: boolean;
|
21 | shift: boolean;
|
22 | };
|
23 | /**
|
24 | The element the keyboard input is performed on.
|
25 | Some behavior might differ if the activeElement changes between corresponding keyboard events.
|
26 | */
|
27 | activeElement: Element | null;
|
28 | /**
|
29 | For HTMLInputElements type='number':
|
30 | If the last input char is '.', '-' or 'e',
|
31 | the IDL value attribute does not reflect the input value.
|
32 | */
|
33 | carryValue?: string;
|
34 | /**
|
35 | Carry over characters to following key handlers.
|
36 | E.g. ^1
|
37 | */
|
38 | carryChar: string;
|
39 | /**
|
40 | Repeat keydown and keypress event
|
41 | */
|
42 | repeatKey?: ReturnType<typeof getNextKeyDef>;
|
43 | };
|
44 | export declare type keyboardOptions = {
|
45 | /** Document in which to perform the events */
|
46 | document: Document;
|
47 | /** Delay between keystrokes */
|
48 | delay: number;
|
49 | /** Add modifiers for given keys - not implemented yet */
|
50 | autoModify: boolean;
|
51 | /** Keyboard layout to use */
|
52 | keyboardMap: keyboardKey[];
|
53 | };
|
54 | export declare enum DOM_KEY_LOCATION {
|
55 | STANDARD = 0,
|
56 | LEFT = 1,
|
57 | RIGHT = 2,
|
58 | NUMPAD = 3
|
59 | }
|
60 | export interface keyboardKey {
|
61 | /** Physical location on a keyboard */
|
62 | code?: string;
|
63 | /** Character or functional key descriptor */
|
64 | key?: string;
|
65 | /** Location on the keyboard for keys with multiple representation */
|
66 | location?: DOM_KEY_LOCATION;
|
67 | /** keyCode for legacy support */
|
68 | keyCode?: number;
|
69 | /** Does the character in `key` require/imply AltRight to be pressed? */
|
70 | altGr?: boolean;
|
71 | /** Does the character in `key` require/imply a shiftKey to be pressed? */
|
72 | shift?: boolean;
|
73 | }
|
74 | export interface behaviorPlugin {
|
75 | matches: (keyDef: keyboardKey, element: Element, options: keyboardOptions, state: keyboardState) => boolean;
|
76 | handle: (keyDef: keyboardKey, element: Element, options: keyboardOptions, state: keyboardState) => void;
|
77 | }
|