Instantsearch.js: Implement a basic keyboard support

Created on 10 Apr 2017  路  3Comments  路  Source: algolia/instantsearch.js

To be able to navigate in an instantsearch.js UI and eventually select an item.

Question

Most helpful comment

All 3 comments

I'm just jumping into Algolia InstantSearch. Really great so far!

I'm looking to add keyboard navigation, specifically support for arrow keys and enter to select a result. Is there currently recommended way to add this to instantsearch results?

@zeke, still needs to be investigated, but I see two options:

  1. listen on keyDown on window and react if the right element is focused (either input, or one of the results)
  2. listen on keyDown on each of the results, as well as on the input

then change the focus to the next or previous hit, or back to the input. Maybe could also be tried by simply adding tabIndex="0" to the results

Was this page helpful?
0 / 5 - 0 ratings