Skip to content

Conversation

@sixfngers
Copy link

The main use case for this functionality is the ability to map a key like the escape button the functionality of a home or back button on a TV remote.

…nd enter.

ex: use case mapping a key to simulate the home button on a tv remote.
focusing on the search field and pressing the space bar mirrors the functionality of pressing the enter button
focusing on the search field and pressing the escape key logs "esc was pressed" to the console
@s4ngu3
Copy link

s4ngu3 commented Jan 14, 2021

is this working?

@sixfngers
Copy link
Author

sixfngers commented Jan 30, 2021

It works for me.
When the focus is on the search bar, pressing the space key or esc key (called out in my commit) will console log a supported key was pressed.

because the feature code is not merged into dead/react-key-navigation repo npm install on the example writes the original repo files into node_modules. If you pull the code from my pull request build the react-key-navigation code and replace examples/youtube-react-tv/node_modules/react-key-navigation/build/ folder with react-key-navigation/build and run the example you will see the console log as stated above.

Steps to get the custom key example running
clone master
cd to react-key-navigation
npm install
npm run-script build

cd examples/youtube-react-tv/
npm install
replace "examples/youtube-react-tv/node_modules/react-key-navigation/build/" folder with the one you just built "react-key-navigation/build"
npm run start-dev

open browser to view example, when the focus is on the search bar at the top, press space or esc and you will see the console log, (spacebar press does same action as enter, esc only has a console log)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants