Options
All
  • Public
  • Public/Protected
  • All
Menu

Class KeybindingRegistry

Hierarchy

  • KeybindingRegistry

Index

Type aliases

Static Match

Match: { binding: ScopedKeybinding; kind: "full" | "partial" } | undefined

Properties

Protected Readonly commandRegistry

commandRegistry: CommandRegistry

Protected Readonly contextProvider

Protected Readonly contexts

contexts: {}

Type declaration

Protected Readonly contributions

Protected Readonly corePreferences

corePreferences: CorePreferences

Protected keySequence

keySequence: KeySequence = []

Protected keybindingsChanged

keybindingsChanged: Emitter<void> = new Emitter<void>()

Protected Readonly keyboardLayoutService

keyboardLayoutService: KeyboardLayoutService

Protected Readonly keymaps

keymaps: ScopedKeybinding[][] = [...Array(KeybindingScope.length)].map(() => [])

Protected Readonly logger

logger: ILogger

Protected Readonly statusBar

statusBar: StatusBar

Protected Readonly toResetKeymap

toResetKeymap: Map<KeybindingScope, Disposable> = new Map<KeybindingScope, Disposable>()

Protected Readonly whenContextService

whenContextService: ContextKeyService

Static Readonly PASSTHROUGH_PSEUDO_COMMAND

PASSTHROUGH_PSEUDO_COMMAND: "passthrough" = "passthrough"

Accessors

onKeybindingsChanged

  • get onKeybindingsChanged(): Event<void>

Methods

acceleratorFor

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

    Parameters

    • keybinding: Keybinding

      the keybinding

    • Default value separator: string = " "

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

    Returns string[]

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

acceleratorForKey

  • acceleratorForKey(key: Key): string

acceleratorForKeyCode

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

    Parameters

    • keyCode: KeyCode

      the keycode

    • Default value separator: string = " "

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

    Returns string

    a string representing the KeyCode

acceleratorForSequence

  • acceleratorForSequence(keySequence: KeySequence, separator?: string): string[]

Protected asKeyboardEventInit

  • asKeyboardEventInit(input: KeyboardEventInit | KeyCode | string): KeyboardEventInit & Partial<{ keyCode: number }>

Protected clearResolvedKeybindings

  • 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

containsKeybindingInScope

dispatchCommand

  • dispatchCommand(id: string, target?: EventTarget): void

dispatchKeyDown

  • dispatchKeyDown(input: KeyboardEventInit | KeyCode | string, target?: EventTarget): void

Protected doRegisterKeybinding

Protected doRegisterKeybindings

Protected executeKeyBinding

  • executeKeyBinding(binding: Keybinding, event: KeyboardEvent): void

Protected getKeySequenceCollisions

getKeybindingsByScope

getKeybindingsForCommand

Protected getUsableBindings

  • getUsableBindings<T>(bindings: T[]): T[]

Protected isActive

Protected isEnabled

  • isEnabled(binding: Keybinding, event: KeyboardEvent): boolean

isPseudoCommand

  • 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

Protected isUsable

matchKeybinding

  • 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

    • keySequence: KeySequence
    • Optional event: KeyboardEvent

    Returns Match

onStart

  • onStart(): Promise<void>

Protected registerContext

  • 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

registerKeybinding

registerKeybindings

resetKeybindings

  • resetKeybindings(): void

resetKeybindingsForScope

resolveKeybinding

run

  • run(event: KeyboardEvent): void

setKeymap

unregisterKeybinding

  • unregisterKeybinding(binding: Keybinding): void
  • unregisterKeybinding(key: string): void
  • unregisterKeybinding(command: Command): void