0
votes

I want to submit a form with react-hook-form using the useHotKeys from react-hotkeys-hook

I have attached a code sandbox trying this. I want to submit a form when a hotkey is clicked as well as when the submit button is clicked. Can this be done?

https://codesandbox.io/s/react-hoot-form-usehotkeys-009rk?file=/src/App.js

1

1 Answers

0
votes

It can be done using the handleSubmit method for react-hook-forms. The mistake that is made is that handleSubmit is a callback, hence it needs to be called like this.

handleSubmit(onSubmit)()

and not like this handleSubmit(onSubmit)