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.

See

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

  • 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

    Example: Define a keybinding which shows a notification

    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
    });
  • 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[]

    Example: Retrieve the current Keybinding Action Bindings

    game.keybindings.get("myModule", "showNotification");
    
  • 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>

    Example: Update the current value of a keybinding

    game.keybindings.set("myModule", "showNotification", [
    {
    key: "F2",
    modifiers: [ "CONTROL" ]
    }
    ]);
  • Reset all client keybindings back to their default configuration.

    Returns Promise<any>

  • Internal

    Register core keybindings.

    Parameters

    • view: string

      The active game view

    Returns void

  • Handle panning the canvas using CTRL + directional keys

    Returns any

  • Private

    Handle keyboard movement once a small delay has elapsed to allow for multiple simultaneous key-presses.

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    • layer: InteractionLayer

      The active InteractionLayer instance

    Returns void

  • Private

    Handle Pan action

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    • movementDirections: string[]

      The Directions being panned in

    Returns boolean

  • Internal

    Compares two Keybinding Actions based on their Order

    Parameters

    • a: KeybindingAction

      The first Keybinding Action

    • b: KeybindingAction

      the second Keybinding Action

    Returns number

  • Private

    A helper method that, when given a value, ensures that the returned value is a standardized Binding array

    Parameters

    • values: KeybindingActionBinding[]

      An array of keybinding assignments to be validated

    Returns KeybindingActionBinding[]

    An array of keybinding assignments confirmed as valid

  • Private

    Validate that assigned modifiers are allowed

    Parameters

    • keys: string[]

      An array of modifiers which may be valid

    Returns string[]

    An array of modifiers which are confirmed as valid

  • Private

    Handle Select all action

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns boolean

  • Private

    Handle Cycle View actions

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns boolean

  • Private

    Handle Dismiss actions

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns Promise<boolean>

  • Private

    Open Character sheet for current token or controlled actor

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns ActorSheet

  • Private

    Handle action to target the currently hovered token.

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns boolean

  • Handle action to send the currently controlled placeables to the back.

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns any

  • Handle action to bring the currently controlled placeables to the front.

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns any

  • Private

    Handle DELETE Keypress Events

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns boolean

  • Private

    Handle Measured Ruler Movement Action

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns boolean

  • Private

    Handle Pause Action

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns boolean

  • Private

    Handle Highlight action

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns boolean

  • Private

    Handle Macro executions

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    • number: number

      The numbered macro slot to execute

    Returns boolean

  • Private

    Handle Macro page swaps

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    • page: number

      The numbered macro page to activate

    Returns boolean

  • Private

    Handle action to copy data to clipboard

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns boolean

  • Private

    Handle Paste action

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns boolean

  • Private

    Handle Undo action

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns boolean

  • Private

    Handle presses to keyboard zoom keys

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    • zoomDirection: {
          IN: string;
          OUT: string;
      }

      The direction to zoom

      • IN: string
      • OUT: string

    Returns boolean

  • Private

    Bring the chat window into view and focus the input

    Parameters

    • context: KeyboardEventContext

      The context data of the event

    Returns boolean