react-hotkeys icon indicating copy to clipboard operation
react-hotkeys copied to clipboard

[Feature] Allow for repeat keys

Open natew opened this issue 6 years ago • 4 comments
trafficstars

Is your feature request related to a problem? Please describe.

I understand repeat keys aren't desired for certain things, but in many cases they are. This proposal is just to make it configurable, likely at the keyMap level, but perhaps at the handler level would be more flexible.

Describe the solution you'd like

<HotKeys
      keyMap={{
        down: 'down',
        up: 'up',
        ...keyMap,
      }}
     repeatable={['down', 'up']}
      style={hotKeyStyle}
      handlers={innerHandlers}
      {...props}
/>

or within the handler

<HotKeys
      keyMap={{
        down: 'down',
        up: 'up',
        ...keyMap,
      }}
>
   <HotKeys handlers={{ down: (e) => { e.repeat } }} />
</HotKeys>

natew avatar Sep 05 '19 17:09 natew

Are you talking about ignoreRepeatedEventsWhenKeyHeldDown: true in the Docs?

ZYinMD avatar Oct 04 '19 04:10 ZYinMD

Yea but having that global isn’t very useful if you have even one case where you’d need both behaviors.

natew avatar Oct 04 '19 05:10 natew

Agreed @natew, I have long wanted to be able to configure all (applicable) options at 3 levels:

  • Globally (currently exists)
  • At the component level (perhaps inherited by children)
  • And at the keymap or handler level

I just haven't had the time to build it in.

greena13 avatar Oct 20 '19 13:10 greena13

@greena13 thanks for this library, it's quite useful! However this issue of not being able to configure repeat option at the keymap/handle level is critical for us. Do you see any chance this getting added any time soon, or if someone created a PR for it?

andrewvarga avatar Oct 29 '20 12:10 andrewvarga