Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface InputManager

Hierarchy

  • InputManager

Index

Methods

bind

  • bind(keyChord: string | string[], actionOrCommand: InputAction | string, filterFunction?: InputFilter): void
  • Bind a key or set of keys to an action

    The action can either be a JavaScript callback, or a command string.

    To see available command strings, check out our KeyBindings file

    filterFunction is an optional third argument. If it returns true, the input binding is enabled. This is helpful, for example, to enable key bindings only in certain conditions.

    An example usage of the filter function might be:

    const isNormalMode = () => oni.editors.activeEditor.mode === "normal"
    const isVisualMode = () => oni.editors.activeEditor.mode === "visual"
    oni.input.bind("<esc>", () => alert("Escape pressed in normal mode!"), isNormalMode)
    oni.input.bind("<esc>", () => alert("Escape pressed in visual mode!"), isVisualMode)
    

    In this case, the isNormalMode and isVisualMode functions are used as filters. When the <esc> key is pressed, all bindings for <esc> are evaluated, and the first one with a passing filter (or no filter) is used.

    Parameters

    Returns void

hasBinding

  • hasBinding(keyChord: string): boolean
  • Parameters

    • keyChord: string

    Returns boolean

unbind

  • unbind(keyChord: string | string[]): void
  • unbind removes an keybindings present on a key.

    unbind is useful for removing default functionality. When your configuration is loaded, the default keybindings provided by Oni are applied, but you can always opt-out of these in order to restore default functionality.

    For example, if I would prefer to use the CtrlP plugin, you could install that plugin, and then use oni.input.unbind("<c-p>") to prevent Oni from opening the bundled file opener. When there are no keybindings present, the input sequence is passed to the active editor (usually Neovim) to handle.

    Parameters

    • keyChord: string | string[]

    Returns void

unbindAll

  • unbindAll(): void

Generated using TypeDoc