react-hotkeys: [BUG] Shortcuts `ctrl+a/x/c/v` doesn't work in Chrome 43

Describe the bug In Chrome 43 shortcuts ctrl+a/x/c/v doesn’t work.

How are you using react hotkeys components? (HotKeys, GlobalHotKeys, IgnoreKeys etc) I use HotKeys

Expected behavior I expect that handlers for ctr+ shortcuts will fire

Platform (please complete the following information):

  • Version of react-hotkeys: 2.0.0-pre4
  • Browser: chrome 43.0.2357.65 m
  • OS: windows 10 enterprise evaluation 1803

Are you willing and able to create a PR request to fix this issue? Might

Include the smallest log that includes your issue:

import * as React from 'react';
import {HotKeys} from 'react-hotkeys';

const keyMap = {
  selectAll: ['command+a', 'ctrl+a'],
  cut: ['command+x', 'ctrl+x'],
  copy: ['command+c', 'ctrl+c'],
  paste: ['command+v', 'ctrl+v'],
};

export default function hotKeysWrapper(WrappedComponent) {
  class HotKeysWrapper extends React.Component {
    ref = React.createRef();

    hotKeyHandlers = {
      selectAll: e => this.selectAll(e),
      copy: () => this.copy(),
      cut: () => this.cut(),
      paste: () => this.paste(),      
    };

    selectAll = e => {
      e.preventDefault();
      ... 
    }

    copy = () => {
      ... 
    }

    cut = () => {
      ... 
    }

    paste = () => {
      ... 
    }

    render() {
      return (
        <HotKeys
          className="container"
          tabIndex="2"
          keyMap={keyMap}
          handlers={this.hotKeyHandlers}
          innerRef={this.ref}
        >
          <WrappedComponent {...this.props} />
        </HotKeys>
      );
    }
  }

  return hotKeysWrapper;
}

What Configuration options are you using? None

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

That’s fantastic. Thanks for getting that, @DMShamonov.

I’m in the middle of a refactor of the package at the moment, but when I am done, I’ll loop back around to this. Re-opening to indicate this is still ongoing.

Ok, as Chrome 43 appears to be supported by React [1] [2] [3], I’ll take a look into some sort of polyfill for when key is not available.