UNPKG

@dotglitch/ngx-common

Version:

Angular components and utilities that are commonly used.

80 lines (79 loc) 2.39 kB
import { Subject } from 'rxjs'; import * as i0 from "@angular/core"; export type KeyCommand = { /** * The non-modifier key(s) that must be pressed for the event to fire. */ key: string | string[]; label?: string; ctrl?: boolean; alt?: boolean; shift?: boolean; super?: boolean; tab?: boolean; /** * Should the handler interrupt default event handling */ interrupt?: boolean; }; /** * Service that listens for global keyboard events */ export declare class KeyboardService { private heldKeys; keyCommands: { ctrl?: boolean; alt?: boolean; shift?: boolean; super?: boolean; interrupt?: boolean; label?: string; keys: string[]; sub: Subject<KeyboardEvent>; }[]; constructor(); private onKeyDown; private onKeyUp; private onKeyPress; /** * Use this to subscribe to keyboard events throughout * the application. This is a passive listener and will * **NOT** interrupt the event chain. */ onKeyCommand(key: KeyCommand): { subscribe: { (observerOrNext?: Partial<import("rxjs").Observer<KeyboardEvent>> | ((value: KeyboardEvent) => void)): import("rxjs").Subscription; (next?: (value: KeyboardEvent) => void, error?: (error: any) => void, complete?: () => void): import("rxjs").Subscription; }; closed: boolean; observers: import("rxjs").Observer<KeyboardEvent>[]; isStopped: boolean; hasError: boolean; thrownError: any; source: import("rxjs").Observable<any>; operator: import("rxjs").Operator<any, KeyboardEvent>; }; /** * Return `true` if shift is currently pressed. */ get isShiftPressed(): boolean; /** * Return `true` if ctrl is currently pressed. */ get isCtrlPressed(): boolean; /** * Return `true` if alt is currently pressed. */ get isAltPressed(): boolean; /** * Return `true` if super (mac/linux) or the windows key is currently pressed. */ get isSuperPressed(): boolean; /** * Return `true` if tab is currently pressed. */ get isTabPressed(): boolean; clearKeys(): void; static ɵfac: i0.ɵɵFactoryDeclaration<KeyboardService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<KeyboardService>; }