trotzig/diffux — pull request #95 by flarnie (2014-04-06 01:43:45+00:00)
Title: Add keyboard shortcuts to jump to top or bottom of page.

(No specs were added to cover keyboard shortcuts - I can add those and push if you want that done before merging the new shortcuts.)

Fixes #79.

Following the conventions of Vim, 'G' jumps to the bottom of the page
and moves the 'focus' to the last focusable element.
The 'g-g' command jumps to the top of the page, moving the 'focus' to
the first focusable element.

The new shortcuts appear in the 'help modal' with explanations.

Also takes the liberty of alphabetizing the shortcut callbacks.

Issues:
* It would be nice to pull the keyboard shortcut binding out into a
library, so one could just pass a hash of shortcuts and handlers into
one method that sets up the right listeners. Something like this:
`shortcutsBind({
'?': openHelpModal,
'G': focusLastFocusable,
'gg': focusFirstFocusable,
...
})
`
* Rewrote the `moveFocus` method to handle jumping to first or last
focusable as well as moving focus forward or backward. Maybe should
further decompose into other methods.

Next Steps:
* Write specs for this (feature specs?)
* Add code for the 'gi' shortcut handler.