Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    A set of helpers and management functions for dealing with user input from keyboard events. https://keycode.info/

    Index

    Properties

    downKeys: Set<string> = ...

    The set of key codes which are currently depressed (down)

    moveKeys: Set<string> = ...

    The set of movement keys which were recently pressed

    panKeys: Set<string> = ...

    The set of panning keys which were recently pressed

    CONTROL_KEY_STRING: string = ...

    The OS-specific string display for what their Command key is

    KEYCODE_DISPLAY_MAPPING: Record<string, string> = ...

    A special mapping of how special KeyboardEvent#code values should map to displayed strings or symbols. Values in this configuration object override any other display formatting rules which may be applied.

    MODIFIER_CODES: { [key: string]: string[] } = ...

    Track which KeyboardEvent#code presses associate with each modifier.

    MODIFIER_KEYS: { ALT: string; CONTROL: string; SHIFT: string } = ...

    Allowed modifier keys.

    PRINTABLE_CHAR_REGEX: RegExp = ...

    Matches any single graphic Unicode code-point (letters, digits, punctuation, symbols, including emoji). Non-printable identifiers like ArrowLeft, ShiftLeft, Dead never match.

    PROTECTED_KEYS: string[] = ...

    Key codes which are "protected" and should not be used because they are reserved for browser-level actions.

    Accessors

    • get hasFocus(): boolean

      Determines whether an HTMLElement currently has focus, which may influence keybinding actions.

      An element is considered to have focus if:

      1. It has a dataset.keyboardFocus attribute explicitly set to "true" or an empty string ("").
      2. It is an <input>, <select>, or <textarea> element, all of which inherently accept keyboard input.
      3. It has the isContentEditable property set to true, meaning it is an editable element.
      4. It is a <button> element inside a <form>, which suggests interactive use.

      An element is considered not focused if:

      1. There is no currently active element (document.activeElement is not an HTMLElement).
      2. It has a dataset.keyboardFocus attribute explicitly set to "false".

      If none of these conditions are met, the element is assumed to be unfocused.

      Returns boolean

    • get isUniversalMode(): boolean

      Is logical keybindings active?

      Returns boolean

    Methods

    • Internal

      Begin listening to keyboard events.

      Returns void

    • Report whether a core action key is currently actively depressed.

      Parameters

      • action: string

        The core action to verify (ex: "target")

      Returns boolean

      Is this core action key currently down (active)?

    • Report whether a modifier in KeyboardManager.MODIFIER_KEYS is currently actively depressed.

      Parameters

      • modifier: string

        A modifier in MODIFIER_KEYS

      Returns boolean

      Is this modifier key currently down (active)?

    • Emulate a key-up event for any currently down keys. When emulating, we go backwards such that combinations such as "CONTROL + S" emulate the "S" first in order to capture modifiers.

      Parameters

      • Optionaloptions: { force?: boolean } = {}

        Options to configure behavior.

        • Optionalforce?: boolean

          Force the keyup events to be handled.

      Returns void

    • Protected

      Release any down keys when focusing a form element.

      Parameters

      • event: FocusEvent

        The focus event.

      Returns void

    • Protected

      Processes a keyboard event context, checking it against registered keybinding actions

      Parameters

      • context: KeyboardEventContext

        The keyboard event context

      • Optionaloptions: { force?: boolean } = {}

        Additional options to configure behavior.

        • Optionalforce?: boolean

          Force the event to be handled.

      Returns void

    • Emulates a key being pressed, triggering the Keyboard event workflow.

      Parameters

      • up: boolean

        If True, emulates the keyup Event. Else, the keydown event

      • code: string

        The KeyboardEvent#code which is being pressed

      • Optionaloptions: {
            altKey?: boolean;
            ctrlKey?: boolean;
            force?: boolean;
            repeat?: boolean;
            shiftKey?: boolean;
        } = {}

        Additional options to configure behavior.

        • OptionalaltKey?: boolean

          Emulate the ALT modifier as pressed

        • OptionalctrlKey?: boolean

          Emulate the CONTROL modifier as pressed

        • Optionalforce?: boolean

          Force the event to be handled.

        • Optionalrepeat?: boolean

          Emulate this as a repeat event

        • OptionalshiftKey?: boolean

          Emulate the SHIFT modifier as pressed

      Returns KeyboardEventContext

    • Format a KeyboardEvent#code into a displayed string.

      Parameters

      • code: string

        The input code

      Returns string

      The displayed string for this code

    • Canonical identifier for a key press.

      Parameters

      • event: KeyboardEvent

      Returns string