A class responsible for managing defined game keybinding. Each keybinding is a string key/value pair belonging to a certain namespace and a certain store scope.

When Foundry Virtual Tabletop is initialized, a singleton instance of this class is constructed within the global Game object as as game.keybindings.

Properties

actions: Map<string, KeybindingActionConfig>

Registered Keybinding actions

activeKeys: Map<string, KeybindingAction[]>

A mapping of a string key to possible Actions that might execute off it

bindings: Map<string, KeybindingActionBinding[]>

A stored cache of Keybind Actions Ids to Bindings

Accessors

  • get moveKeys(): Set<string>

    An alias of the movement key set tracked by the keyboard

    Returns Set<string>

Methods

  • Internal

    Register core keybindings.

    Parameters

    • view: string

      The active game view

    Returns void

  • Get the current Bindings of a given namespace's Keybinding Action

    Parameters

    • namespace: string

      The namespace under which the setting is registered

    • action: string

      The keybind action to retrieve

    Returns KeybindingActionBinding[]

    game.keybindings.get("myModule", "showNotification");
    
  • Initializes the keybinding values for all registered actions

    Returns void

  • Register a new keybinding

    Parameters

    • namespace: string

      The namespace the Keybinding Action belongs to

    • action: string

      A unique machine-readable id for the Keybinding Action

    • data: KeybindingActionConfig

      Configuration for keybinding data

    Returns void

    game.keybindings.register("myModule", "showNotification", {
    name: "My Settings Keybinding",
    hint: "A description of what will occur when the Keybinding is executed.",
    uneditable: [
    {
    key: "Digit1",
    modifiers: ["Control"]
    }
    ],
    editable: [
    {
    key: "F1"
    }
    ],
    onDown: () => { ui.notifications.info("Pressed!") },
    onUp: () => {},
    restricted: true, // Restrict this Keybinding to gamemaster only?
    reservedModifiers: ["Alt"], // On ALT, the notification is permanent instead of temporary
    precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL
    });
  • Reset all client keybindings back to their default configuration.

    Returns Promise<any>

  • Set the editable Bindings of a Keybinding Action for a certain namespace and Action

    Parameters

    • namespace: string

      The namespace under which the Keybinding is registered

    • action: string

      The Keybinding action to set

    • bindings: KeybindingActionBinding[]

      The Bindings to assign to the Keybinding

    Returns Promise<any>

    game.keybindings.set("myModule", "showNotification", [
    {
    key: "F2",
    modifiers: [ "CONTROL" ]
    }
    ]);
  • Internal

    Compares two Keybinding Actions based on their Order

    Parameters

    Returns number