greena13 / react-hotkeys

Declarative hotkey and focus area management for React
https://github.com/greena13/react-hotkeys
ISC License
2.15k stars 161 forks source link

GlobalHotKeys not working when focused on the input field. #274

Closed Gajesh-LH closed 4 years ago

Gajesh-LH commented 4 years ago

Describe the bug GlobalHotKeys not working when focused on the input field.

Demo (Recorded Screen Link): https://recordit.co/ffVKvn9uVw

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

<GlobalHotKeys keyMap={REGISTRATION_KEY_MAP} handlers={this.handlers}>
      <RegistrationForm
         ref={regFormRef}
         onBillClick={this.onBillClick}
         patientId={this.state.patientID}
         openBill={this.state.openBill}
     />
</GlobalHotKeys>

    const handlers = {
        REGISTER: () => console.log(regFormRef),
        REGISTER_AND_BILL:  () => console.log(regFormRef),
    };

  const REGISTRATION_KEY_MAP = {
    REGISTER: ['command+enter', 'ctrl+enter'],
    REGISTER_AND_BILL: ['enter'],
  };

Expected behavior

If I am using then it should directly fire the related action, the focus should not matter. Eg. I want to submit a form but currently, document focused on any input box then it should submit the form

Platform (please complete the following information):

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

Include the smallest log that includes your issue:

What Configuration options are you using?

Gajesh-LH commented 4 years ago
configure({
    ignoreTags: ['input', 'select', 'textarea'],
    ignoreEventsCondition: function() {}
});

Using this config. we can solve this issue.