@violentmonkey/shortcut

  • Version 1.4.4
  • Published
  • 34.2 kB
  • 1 dependency
  • ISC license

Install

npm i @violentmonkey/shortcut
yarn add @violentmonkey/shortcut
pnpm add @violentmonkey/shortcut

Overview

Register a shortcut for a function

Index

Variables

variable aliases

const aliases: Record<string, string>;

    variable isMacintosh

    const isMacintosh: boolean;

      variable modifierAliases

      const modifierAliases: Record<string, 'm' | 'c' | 's' | 'a'>;

        variable modifierList

        const modifierList: readonly ['m', 'c', 's', 'a'];

          variable modifiers

          const modifiers: Record<string, 'm' | 'c' | 's' | 'a'>;

            variable modifierSymbols

            const modifierSymbols: { c: string; s: string; a: string; m: string };

              variable version

              const version: string;

                Functions

                function buildKey

                buildKey: (key: IShortcutKey) => string;

                  function disable

                  disable: () => void;

                    function enable

                    enable: () => void;

                      function getService

                      getService: () => KeyboardService;

                        function handleKey

                        handleKey: (e: KeyboardEvent) => void;

                          function normalizeSequence

                          normalizeSequence: (
                          input: string | string[],
                          caseSensitive: boolean
                          ) => IShortcutKey[];

                            function parseCondition

                            parseCondition: (condition: string) => IShortcutCondition[];

                              function parseKey

                              parseKey: (shortcut: string, caseSensitive: boolean) => IShortcutKey;

                                function register

                                register: (
                                key: string,
                                callback: () => void,
                                options?: Partial<IShortcutOptions> | undefined
                                ) => () => void;

                                  function reprKey

                                  reprKey: (key: IShortcutKey) => string;

                                    function reprShortcut

                                    reprShortcut: (input: string | string[], caseSensitive?: boolean) => string;

                                      Classes

                                      class KeyboardService

                                      class KeyboardService {}

                                        constructor

                                        constructor(options?: Partial<IShortcutServiceOptions>);

                                          property defaultOptions

                                          static defaultOptions: IShortcutServiceOptions;

                                            property handleKey

                                            handleKey: (e: KeyboardEvent) => void;

                                              property options

                                              options: IShortcutServiceOptions;

                                                property sequence

                                                sequence: Subject<string[]>;

                                                  method disable

                                                  disable: () => void;

                                                    method enable

                                                    enable: () => void;

                                                      method register

                                                      register: (
                                                      key: string,
                                                      callback: () => void,
                                                      options?: Partial<IShortcutOptions>
                                                      ) => () => void;

                                                        method repr

                                                        repr: () => string;

                                                          method setContext

                                                          setContext: (key: string, value: unknown) => void;

                                                            Interfaces

                                                            interface IKeyNode

                                                            interface IKeyNode {}

                                                              property children

                                                              children: Map<string, IKeyNode>;

                                                                property shortcuts

                                                                shortcuts: Set<IShortcut>;

                                                                  interface IShortcut

                                                                  interface IShortcut {}

                                                                    property callback

                                                                    callback: () => void;

                                                                      property caseSensitive

                                                                      caseSensitive: boolean;

                                                                        property condition

                                                                        condition?: string;

                                                                          property enabled

                                                                          enabled: boolean;

                                                                            property sequence

                                                                            sequence: string[];

                                                                              interface IShortcutCondition

                                                                              interface IShortcutCondition {}

                                                                                property field

                                                                                field: string;

                                                                                  property not

                                                                                  not: boolean;

                                                                                    interface IShortcutConditionCache

                                                                                    interface IShortcutConditionCache {}

                                                                                      property count

                                                                                      count: number;

                                                                                        property result

                                                                                        result: boolean;

                                                                                          property value

                                                                                          value: IShortcutCondition[];

                                                                                            interface IShortcutKey

                                                                                            interface IShortcutKey {}

                                                                                              property base

                                                                                              base: string;

                                                                                                property caseSensitive

                                                                                                caseSensitive: boolean;

                                                                                                  property modifierState

                                                                                                  modifierState: IShortcutModifiers;

                                                                                                    interface IShortcutModifiers

                                                                                                    interface IShortcutModifiers {}

                                                                                                      property a

                                                                                                      a?: boolean;

                                                                                                        property c

                                                                                                        c?: boolean;

                                                                                                          property m

                                                                                                          m?: boolean;

                                                                                                            property s

                                                                                                            s?: boolean;

                                                                                                              interface IShortcutOptions

                                                                                                              interface IShortcutOptions {}

                                                                                                                property caseSensitive

                                                                                                                caseSensitive: boolean;

                                                                                                                  property condition

                                                                                                                  condition?: string;

                                                                                                                    interface IShortcutServiceOptions

                                                                                                                    interface IShortcutServiceOptions {}

                                                                                                                      property sequenceTimeout

                                                                                                                      sequenceTimeout: number;
                                                                                                                      • Max timeout between two keys within a sequence.

                                                                                                                      Type Aliases

                                                                                                                      type IModifier

                                                                                                                      type IModifier = (typeof modifierList)[number];

                                                                                                                        Package Files (4)

                                                                                                                        Dependencies (1)

                                                                                                                        Dev Dependencies (7)

                                                                                                                        Peer Dependencies (0)

                                                                                                                        No peer dependencies.

                                                                                                                        Badge

                                                                                                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@violentmonkey/shortcut.

                                                                                                                        • Markdown
                                                                                                                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@violentmonkey/shortcut)
                                                                                                                        • HTML
                                                                                                                          <a href="https://www.jsdocs.io/package/@violentmonkey/shortcut"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>