Tutorials

API Reference

Improve this doc View source

keyBindings

  1. - service in module voorhoede.components.keyBindings

Manages the grouping of key combos and handlers, and (un)binds combos at appropriate moments using Mousetrap.

Methods

  • addHandler(handler);

    Parameters

    Param Type Details
    handler object

    Handler object that should contain at least:

    • combo: A key combo that will be passed to Mousetrap. List of supported keys
    • handler: Function that will be used as event handler. Passed arguments:
      • event: The event object
      • combo: The combo that triggered the event

    You can add any additional properties that you may want to use later (e.g., you can pass a description if you want to be able to generate a human-readable cheat sheet of active key bindings.)

    Returns

    function

    Function to remove the handler.

  • bindCombo(combo);

    Binds triggerHandlers() to the specified key combo using Mousetrap.

    Parameters

    Param Type Details
    combo string
  • unbindCombo(combo);

    Unbinds the specified key combo using Mousetrap.

    Parameters

    Param Type Details
    combo string
  • triggerHandlers(handlers, event, combo);

    Triggers the appropriate handlers in the provided group. This means in any case the last one, and the next handler for each handler that returns true.

    Parameters

    Param Type Details
    handlers array
    event object
    combo string

Properties

  • comboGroups

    Contains all currently active handlers, grouped by key combo.