我在 React 项目中使用 React-hotkeys 作为键盘快捷键。GlobalHotKeys 在专注于输入字段时不起作用。请帮助我,我无法找出我错过了什么。
演示(录屏链接):https ://recordit.co/ffVKvn9uVw
<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'],
};
预期行为
如果我正在使用,那么它应该直接触发相关动作,焦点应该无关紧要。例如。我想提交一个表单,但目前,文档集中在任何输入框上,然后它应该提交表单
平台:
- 反应热键版本:
react-hotkeys v2.0.0
- 浏览器镀铬
- 操作系统:iOS v10.13.6