Skip to content

[BUG] useHotkeys callback is missing hotkey #1286

@ljani

Description

@ljani

Describe the bug
According to the documentation, useHotkeys' callback should have a property called hotkey (see "Also you could work directly with hotkey trigger:"), but it disappeared with v5. This is working fine in v4.

hotkey property is very useful to distinguish between eg. shift+a and ctrl+a if there are lots of combinations in one callback (I'm using it for context menu with many, dynamic entries)

To Reproduce
Steps to reproduce the behavior:

  1. Create a (TypeScript) project
  2. Call:
useHotkeys(["ctrl+a", "shift+a"], (e, handler) => console.log(handler.hotkey));

Stackblitz: https://stackblitz.com/edit/vitejs-vite-qhkqevmj?file=src%2FApp.tsx

Actual behavior
undefined is logged

Expected behavior
Either ctrl+a or shift+a should be logged

Desktop (please complete the following information):

  • Version: v5.1.0

Additional context

hotkey disappeared from parseHotkey between v4.6.2...v5.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions