UNPKG

2.32 kBTypeScriptView Raw
1import { NativeKeyboardLayout, KeyboardLayoutProvider, KeyboardLayoutChangeNotifier, KeyValidator } from '../../common/keyboard/keyboard-layout-provider';
2import { Emitter, Event } from '../../common/event';
3import { KeyCode, Key } from './keys';
4export interface KeyboardLayout {
5 /**
6 * Mapping of standard US keyboard keys to the actual key codes to use.
7 * See `KeyboardLayoutService.getCharacterIndex` for the index computation.
8 */
9 readonly key2KeyCode: KeyCode[];
10 /**
11 * Mapping of KeyboardEvent codes to the characters shown on the user's keyboard
12 * for the respective keys.
13 */
14 readonly code2Character: {
15 [code: string]: string;
16 };
17}
18export declare class KeyboardLayoutService {
19 protected readonly layoutProvider: KeyboardLayoutProvider;
20 protected readonly layoutChangeNotifier: KeyboardLayoutChangeNotifier;
21 protected readonly keyValidator?: KeyValidator;
22 private currentLayout?;
23 protected updateLayout(newLayout: NativeKeyboardLayout): KeyboardLayout;
24 protected keyboardLayoutChanged: Emitter<KeyboardLayout>;
25 get onKeyboardLayoutChanged(): Event<KeyboardLayout>;
26 initialize(): Promise<void>;
27 /**
28 * Resolve a KeyCode of a keybinding using the current keyboard layout.
29 * If no keyboard layout has been detected or the layout does not contain the
30 * key used in the KeyCode, the KeyCode is returned unchanged.
31 */
32 resolveKeyCode(inCode: KeyCode): KeyCode;
33 /**
34 * Return the character shown on the user's keyboard for the given key.
35 * Use this to determine UI representations of keybindings.
36 */
37 getKeyboardCharacter(key: Key): string;
38 /**
39 * Called when a KeyboardEvent is processed by the KeybindingRegistry.
40 * The KeyValidator may trigger a keyboard layout change.
41 */
42 validateKeyCode(keyCode: KeyCode): void;
43 protected transformKeyCode(inCode: KeyCode, mappedCode: KeyCode, keyNeedsShift: boolean): KeyCode | undefined;
44 protected transformNativeLayout(nativeLayout: NativeKeyboardLayout): KeyboardLayout;
45 protected shouldIncludeKey(code: string): boolean;
46 private addKeyMapping;
47 private addWindowsKeyMapping;
48 protected getCharacterIndex(key: Key, shift?: boolean): number;
49}
50//# sourceMappingURL=keyboard-layout-service.d.ts.map
\No newline at end of file