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

backspace and delete shortcuts fire when input is focused

Open wouterh opened this issue 6 years ago • 1 comments

The delete and backspace keys should be treated in the same way as regular keys when an input is focused as they are needed for text input. This is currently not the case.

See this example: https://codesandbox.io/s/zrp902nkzl

wouterh avatar Jul 02 '18 08:07 wouterh

Hi!

To accomplish what you are trying to do, you need to add the property alwaysFireHandler="true" to ensure that, when certain keys are pressed on an active element (like an input) the shortcut executes correctly.

Code should be modified like this:

return (
    <Shortcuts name="BOX" 
    handler={handleMove} 
    alwaysFireHandler="true" >

      <div style={style} name="test">
        {index + 1}
        <input type="text" />
      </div>

    </Shortcuts>
  );

and it should do the trick :)

The modified codesandbox code can be found here

jalmarazg avatar Jul 29 '18 07:07 jalmarazg