Skip to content

Enter key press to next input field (Tab behaviour) #2543

Answered by johnrom
sanojsilva asked this question in General
Discussion options

You must be logged in to vote

Hi @sanojsilva,

There is currently no way to implement this in Formik itself. You can attach an onKeyUp handler to all your inputs, and prevent event.preventDefault() when event.key === 'Enter'. You may have to use onKeyPress in React Native, if you're using it. On textareas, you should check to make sure event.shiftKey is pressed, because enter normally makes a newline in textareas, while shift+enter submits.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@sanojsilva
Comment options

@johnrom
Comment options

johnrom Jun 24, 2020
Collaborator

@sanojsilva
Comment options

@filipeferreira-dev
Comment options

Answer selected by sanojsilva
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants