argyleink / roving-ux

stateful roving index for web ui
130 stars 7 forks source link

Ability to set prev and next keys #4

Closed kunukn closed 3 years ago

kunukn commented 3 years ago

I have a use case where I want to use the up and down keys for the previous and next focus.

API usage example

rovingIndex({
  element: document.querySelector('#vertical-accordions'),
  target: '.toggle',
  prev: ['ArrowUp'],
  next: ['ArrowDown'],
})
argyleink commented 3 years ago

nice, great feature request! what do you think of setting direction instead of passing arrays with strings?

rovingIndex({
  element: document.querySelector('#vertical-accordions'),
  target: '.toggle',
  direction: 'vertical',
})

internally, 'vertical' would use the up/down arrows to move through the targets. horizontal would be default.

OR

what if the library mapped up/down arrow keys to left/right, so direction didnt matter? down and right are the same, and up and left are the same? "just works."

kunukn commented 3 years ago

Sounds better than my suggestion :)

I like this one

what if the library mapped up/down arrow keys to left/right, so direction didnt matter? down and right are the same, and up and left are the same? "just works."

kunukn commented 3 years ago

I have created this alternative PR

5

argyleink commented 3 years ago

closing as the feature merged in the other PR!