Skip to content
FrameworkStyle

useHotkey

Hook that registers a keyboard shortcut for the current Player

Import

import { useHotkey } from "@videojs/react";

Usage

Call the hook inside Player with the accepted keys and activation callback.

function CustomPlayHotkey() {
  useHotkey({
    keys: "k",
    onActivate: (_event, key) => console.log(`Activated by ${key}`),
  });

  return null;
}

Shortcuts target the player by default and accept repeated keydown events. Set target to "document", repeatable to false, or disabled to change those behaviors. The hook still requires a surrounding Player for its coordinator.

API Reference

Parameters

ParameterTypeDefaultDetails
options*object

Return Value

void