NoriginMedia / react-spatial-navigation

DEPRECATED. HOC-based Spatial Navigation. NEW Hooks version is available here: https://github.com/NoriginMedia/norigin-spatial-navigation
MIT License
226 stars 64 forks source link

Custom keyMap via setKeyMap does not work #58

Closed stuartflanagan closed 4 years ago

stuartflanagan commented 4 years ago

Describe the bug Documentation implies that initialising the library and setting a key map should be done with the following property names from: https://github.com/NoriginMedia/react-spatial-navigation#initialization

// Optional
setKeyMap({
  'left': 9001,
  'up': 9002,
  'right': 9003,
  'down': 9004,
  'enter': 9005
});

Using these name value pairs does not seem to work.

Expected behavior Should be able to set a device specific key map for left, right, up, down & enter.

asgvard commented 4 years ago

Hi,

I have tried to reproduce this issue and I couldn't. I passed custom key map where I "inverted" left and right codes and it is fine. We are also using this feature on some projects where TV devices provide different key codes from a "default" browser ones. Can you provide more details about which environment and device you're working on? Do you have a possibility to debug it with "debug: true" and see what is the direction of the navigation?

stuartflanagan commented 4 years ago

setKeyMap works for us if we use:

// Optional
setKeyMap({
 'ArrowLeft': 9001,
 'ArrowUp': 9002,
 'ArrowRight': 9003,
 'ArrowDown': 9004,
 'Enter': 9005
});

Is there documentation on what property names are valid for the key map?

stuartflanagan commented 4 years ago

Sorry for the confusion. You are correct and this is working as intended.