Reference - BaklavaJS
    Preparing search index...
    interface ICommandHandler {
        pressedKeys: string[];
        canExecuteCommand<T extends AbstractCommand>(
            name: string,
            throwOnNonexisting?: boolean,
            ...args: Parameters<T["execute"]>,
        ): boolean;
        executeCommand<T extends AbstractCommand>(
            name: string,
            throwOnNonexisting?: false,
            ...args: Parameters<T["execute"]>,
        ): void | ReturnType<T["execute"]>;
        executeCommand<T extends AbstractCommand>(
            name: string,
            throwOnNonexisting: true,
            ...args: Parameters<T["execute"]>,
        ): ReturnType<T["execute"]>;
        handleKeyDown(ev: KeyboardEvent): void;
        handleKeyUp(ev: KeyboardEvent): void;
        hasCommand(name: string): boolean;
        registerCommand<T extends AbstractCommand>(name: string, command: T): void;
        registerHotkey(
            keys: string[],
            commandName: string,
            options?: HotkeyRegistrationOptions,
        ): void;
    }
    Index

    Properties

    pressedKeys: string[]

    Currently pressed keys

    Methods

    • Checks whether the command can be executed at the present time.

      Type Parameters

      • T extends AbstractCommand

      Parameters

      • name: string

        Name of the command

      • OptionalthrowOnNonexisting: boolean

        Whether to throw an error if the command with the specified name does not exist. If set to false and the command doesn't exist, the method will just return false.

      • ...args: Parameters<T["execute"]>

      Returns boolean

    • Executes the command with the given name

      Type Parameters

      • T extends AbstractCommand

      Parameters

      • name: string

        Name of the command

      • OptionalthrowOnNonexisting: false

        Whether to throw an error if the command with the specified name does not exist. If set to false and the command doesn't exist, the method will just return undefined.

      • ...args: Parameters<T["execute"]>

      Returns void | ReturnType<T["execute"]>

    • Executes the command with the given name

      Type Parameters

      • T extends AbstractCommand

      Parameters

      • name: string

        Name of the command

      • throwOnNonexisting: true

        Whether to throw an error if the command with the specified name does not exist. If set to false and the command doesn't exist, the method will just return undefined.

      • ...args: Parameters<T["execute"]>

      Returns ReturnType<T["execute"]>

    • Whether the command with the given name exists

      Parameters

      • name: string

        Name of the command

      Returns boolean

    • Register a new command

      Type Parameters

      • T extends AbstractCommand

      Parameters

      • name: string

        Name of the command

      • command: T

        Command definition

      Returns void

    • Register a new hotkey combination for the command.

      Parameters

      • keys: string[]

        Combination of keys. When all keys in the given array are pressed at the same time, the command will be executed.

      • commandName: string

        Name of the command that should be executed when the keys are pressed.

      • Optionaloptions: HotkeyRegistrationOptions

        Options for the hotkey registration.

      Returns void