Options
All
  • Public
  • Public/Protected
  • All
Menu

Class KeybindingRegistry

Hierarchy

  • KeybindingRegistry

Index

Constructors

Properties

commandRegistry: CommandRegistry
contexts: {} = {}

Type declaration

corePreferences: CorePreferences
keySequence: KeySequence = []
keybindingsChanged: Emitter<void> = ...
keyboardLayoutService: KeyboardLayoutService
keymaps: ScopedKeybinding[][] = ...
logger: ILogger
statusBar: StatusBar
toResetKeymap: Map<KeybindingScope, Disposable> = ...
whenContextService: ContextKeyService
PASSTHROUGH_PSEUDO_COMMAND: "passthrough" = 'passthrough'

Accessors

  • get onKeybindingsChanged(): Event<void>

Methods

  • acceleratorFor(keybinding: Keybinding, separator?: string, asciiOnly?: boolean): string[]
  • Get a user visible representation of a {@link common.Keybinding}.

    Parameters

    • keybinding: Keybinding

      the keybinding

    • separator: string = ' '

      the separator to be used to stringify KeyCodes that are part of the KeySequence

    • asciiOnly: boolean = false

    Returns string[]

    an array of strings representing all elements of the KeySequence defined by the {@link common.Keybinding}

  • acceleratorForKey(key: Key, asciiOnly?: boolean): string
  • Parameters

    • key: Key
    • asciiOnly: boolean = false

      if true, no special characters will be substituted into the string returned. Ensures correct keyboard shortcuts in Electron menus.

      Return a user visible representation of a single key.

    Returns string

  • acceleratorForKeyCode(keyCode: KeyCode, separator?: string, asciiOnly?: boolean): string
  • Get a user visible representation of a key code (a key with modifiers).

    Parameters

    • keyCode: KeyCode

      the keycode

    • separator: string = ' '

      the separator used to separate keys (key and modifiers) in the returning string

    • asciiOnly: boolean = false

      if true, no special characters will be substituted into the string returned. Ensures correct keyboard shortcuts in Electron menus.

    Returns string

    a string representing the KeyCode

  • acceleratorForSequence(keySequence: KeySequence, separator?: string, asciiOnly?: boolean): string[]
  • asKeyboardEventInit(input: string | KeyCode | KeyboardEventInit): KeyboardEventInit & Partial<{ keyCode: number }>
  • clearResolvedKeybindings(): void
  • Clear all resolved properties of registered keybindings so the KeyboardLayoutService is called again to resolve them. This is necessary when the user's keyboard layout has changed.

    Returns void

  • componentsForKeyCode(keyCode: KeyCode, asciiOnly?: boolean): string[]
  • dispatchCommand(id: string, target?: EventTarget): void
  • dispatchKeyDown(input: string | KeyCode | KeyboardEventInit, target?: EventTarget): void
  • executeKeyBinding(binding: Keybinding, event: KeyboardEvent): void
  • getUsableBindings<T>(bindings: T[]): T[]
  • isEnabled(binding: Keybinding, event: KeyboardEvent): boolean
  • isPseudoCommand(commandId: string): boolean
  • Return true of string a pseudo-command id, in other words a command id that has a special meaning and that we won't find in the command registry.

    Parameters

    • commandId: string

      commandId to test

    Returns boolean

  • Match first binding in the current context. Keybindings ordered by a scope and by a registration order within the scope.

    FIXME: This method should run very fast since it happens on each keystroke. We should reconsider how keybindings are stored. It should be possible to look up full and partial keybinding for given key sequence for constant time using some kind of tree. Such tree should not contain disabled keybindings and be invalidated whenever the registry is changed.

    Parameters

    Returns KeybindingRegistry.Match

  • onStart(): Promise<void>
  • Registers the keybinding context arguments into the application. Fails when an already registered context is being registered.

    Parameters

    • Rest ...contexts: KeybindingContext[]

      the keybinding contexts to register into the application.

    Returns void

  • resetKeybindings(): void
  • run(event: KeyboardEvent): void
  • unregisterKeybinding(binding: Keybinding): void
  • unregisterKeybinding(key: string): void
  • unregisterKeybinding(command: Command): void