Skip to content

registerHotkey(hotkey)

registerHotkey registers a hot key globally.

Reference

typescript
(hotkey: {
  name: string
  keys: string | string[]
  preventDefault?: boolean
  stopPropagation?: boolean
  check?: (params: {
    chart: Chart
    event: KeyboardEvent
    key: string
    hotkey: HotkeyTemplate
  }) => boolean
  action: (params: {
    chart: Chart
    event: KeyboardEvent
    key: string
    hotkey: HotkeyTemplate
  }) => void
  extendData?: any
}) => void

Parameters

  • hotkey Hot key configuration.
    • name Name, used as the global unique identifier. Registering the same name again overrides the existing configuration.
    • keys Key combination, can be a string or a string array, such as R, Shift+Equal, or ['Shift+=', 'Shift+NumpadAdd'].
    • preventDefault Whether to prevent the browser default behavior, default is true.
    • stopPropagation Whether to stop event propagation, default is false.
    • check Check before execution. When it returns false, action will not run.
      • params.chart Chart instance that triggered the hot key.
      • params.event Original keyboard event.
      • params.key Normalized key string.
      • params.hotkey Current hot key configuration.
    • action Method executed when the hot key is triggered. It receives the same params as check.
    • extendData Custom extension data.

Returns

registerHotkey returns undefined .

Usage

Basic usage