Options
All
  • Public
  • Public/Protected
  • All
Menu

Class KeyCode

Representation of a pressed key combined with key modifiers.

Hierarchy

  • KeyCode

Index

Type aliases

Static Predicate

Predicate: (keyCode: KeyCode) => boolean

Determines a true of false value for the key code argument.

Type declaration

    • Parameters

      Returns boolean

Constructors

constructor

Properties

Readonly alt

alt: boolean

Readonly character

character: string | undefined

Readonly ctrl

ctrl: boolean

Readonly key

key: Key | undefined

Readonly meta

meta: boolean

Readonly shift

shift: boolean

Static Private keybindings

keybindings: {}

Type declaration

Methods

equals

isModifierOnly

  • isModifierOnly(): boolean

toString

  • toString(): string

Static createKeyCode

Static isKeyboardEvent

  • isKeyboardEvent(event: object & { type?: undefined | string }): event is KeyboardEvent
  • Different scopes have different execution environments. This means that they have different built-ins (different global object, different constructors, etc.). This may result in unexpected results. For instance, [] instanceof window.frames[0].Array will return false, because Array.prototype !== window.frames[0].Array and arrays inherit from the former. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof

    Note: just add another check if the current event.type checking is insufficient.

    Parameters

    • event: object & { type?: undefined | string }

    Returns event is KeyboardEvent

Static isModifierString

  • isModifierString(key: string): boolean

Static parse

  • parse(keybinding: string): KeyCode

Static resetKeyBindings

  • resetKeyBindings(): void

Static toCharacter

  • toCharacter(event: KeyboardEvent): string | undefined
  • Determine the actual printable character that is generated from a pressed key. If the key does not correspond to a printable character, undefined is returned. The result may be altered by modifier keys.

    Parameters

    • event: KeyboardEvent

    Returns string | undefined

Static toKey

  • toKey(event: KeyboardEvent, dispatch?: "code" | "keyCode"): Key