1

I'm building a simple word game on the web (for the sake of example, think Wordle) and the Enter key has a role in this, submitting the letters you've typed in.

The trouble is that if a user is tabbing around and using the enter key to interact with different screen elements, this is a bit problematic. Whatever they have selected will activate in addition to submitting the letters you've typed. I can use preventDefault to stop the two from conflicting, but then it's impossible to navigate with the keyboard.

Is there a way to reconcile these two things?

1 Answer 1

1

There's two good solutions for this:

  • A common pattern (used eg by checkboxes) is that Space selects the focused option. So if your game revolves around selecting various elements and then submitting the selection as a solution, this would be your pattern.
  • Another common pattern is to put "submit" on Shift+Enter or Ctrl+Enter (or both!). This is typically done in chat apps, where you want the user to be able to do line breaks but also be able to send quickly. It also can be flipped around. In these cases, you would need a small "Ctrl+Enter to submit" hint in your UI

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.