All skills

Practical playbook for React teams to choose and apply reactuse hooks across state, async flows, browser APIs, and UI interactions. Use it when replacing custom hook logic with production-ready patterns that stay compatible with SSR and Next.js.

Use this Skill: https://skilld.dev/gh/siberiacancode/agent-skills/reactuse

This session only. Nothing lands on disk.

rulesuseHotkeys.md

≈524 tokens on demand. Your agent reads this file only when SKILL.md points to it.

useHotkeys

Scopes keyboard shortcuts to a target or returned ref so command-style interactions can stay close to the component that owns them.

Usage

import { useHotkeys } from "@siberiacancode/reactuse";

const ref = useHotkeys<HTMLDivElement>("ctrl+k", () => console.log("hotkey"));
// or
useHotkeys(ref, "ctrl+k", () => console.log("hotkey"));

Example

const ref = useHotkeys<HTMLDivElement>("mod+k,ctrl+/", () => {
  console.log("open command menu");
});

return <div ref={ref}>Open</div>;

enabled:

const ref = useHotkeys<HTMLDivElement>("ctrl+k", () => {}, { enabled: false });

alias:

const ref = useHotkeys<HTMLDivElement>("cmd+k", openMenu, {
  alias: { Meta: "cmd" },
});

onChange:

const ref = useHotkeys<HTMLDivElement>("escape", {
  onChange: (event) => console.log(event.key),
});

hotkeys alternatives:

const ref = useHotkeys<HTMLDivElement>("mod+k,ctrl+/", openMenu);

Type Declarations

import type { HookTarget, StateRef } from "@siberiacancode/reactuse";

export interface UseHotkeysOptions {
  alias?: Record<string, string>;
  enabled?: boolean;
  onChange?: (event: KeyboardEvent) => void;
}
export type UseHotkeysHotkeys = string;
export interface UseHotkeysKey {
  alias: string;
  code: string;
  key: string;
}
export declare const isHotkeyMatch: (
  hotkey: string,
  keys: UseHotkeysKey[]
) => boolean;
export interface UseHotkeys {
  (
    target: HookTarget,
    hotkeys: UseHotkeysHotkeys,
    options?: UseHotkeysOptions
  ): void;
  (
    target: HookTarget,
    hotkeys: UseHotkeysHotkeys,
    callback: (event: KeyboardEvent) => void,
    options?: UseHotkeysOptions
  ): void;
  <Target extends Element>(
    hotkeys: UseHotkeysHotkeys,
    options?: UseHotkeysOptions
  ): StateRef<Target>;
  <Target extends Element>(
    hotkeys: UseHotkeysHotkeys,
    callback: (event: KeyboardEvent) => void,
    options?: UseHotkeysOptions
  ): StateRef<Target>;
}
export declare const useHotkeys: UseHotkeys;

Source: SKILL.md on GitHub

No alerts16d4 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill is a comprehensive documentation and implementation guide for the Reactuse hook library, designed for React and Next.js projects. It provides clear rules, usage examples, and type declarations for a wide range of hooks, including those interacting with browser APIs. No malicious patterns, obfuscation, or security risks were detected.

  • Socket5mo

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    1/166 files flagged

Signed by skilld at a090849. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated last month
metadata
{
  "author": "siberiacancode",
  "version": "1.0.16"
}

README badge

README badge for siberiacancode/agent-skills/reactuse