davidtheclark / focus-group

Create a group of nodes with special focusing powers

Home Page:http://davidtheclark.github.io/focus-group/demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

more options for forwardArrows and backArrows options

souporserious opened this issue · comments

How do you feel about allowing more ARIA keyboard controls for these options? Things like pageUp and pageDown? More can be seen here in the keyboard control section: https://www.w3.org/TR/2013/WD-wai-aria-practices-20130307/#accordion

I'm glad to do a PR for this as well if you would like :) maybe rename them to something like nextControls and prevControls?

Hm, interesting. We could make it even more flexible than adding a couple more keywords. Maybe we should open it to arbitrary keyboard events?

Here's a idea: We have a keybindings object. We start with next and prev properties (but since it's an object we could add first, last, or other properties later). And you provide as values objects (or arrays of objects) that describe the requirements of a KeyboardEvent that should trigger that keybinding.

Default would look like this:

var myFocusGroup = createFocusGroup({
  keybindings: {
    next: { keyCode: 40 } // ArrowDown
    prev: { keyCode: 38 } // ArrowUp
  }
});

And let's say you also want ctrl+k and Space to be next, and ctrl+j to be prev:

var myFocusGroup = createFocusGroup({
  keybindings: {
    next: [
      { keyCode: 40 }, // ArrowDown
      { keyCode: 32 }, // Space
      { keyCode: 75, ctrlKey: true }, // ctrl+k
    ],
    prev: [
      { keyCode: 38 }, // ArrowUp
      { keyCode: 74, ctrlKey: true }, // ctrl+j
    ]
  }
});

What do you think of that idea, @souporserious?

Love it! I'll work on a PR 😃

Thanks for the PR, @souporserious. That functionality is merged now. Before we release, though, we need to do a couple of things:

  • Update the readme and changelog.
  • Add tests to ensure that arrays of keybindings and keybindings with multiple properties work.

Want to pull off another PR based on master for those parts?

Done :) #6

Published in 0.3.0.

Thanks! Really happy with how that turned out 😃

Me too. Thanks for sticking it out and collaborating with me!