Add de-registering functionality to keyCapture

The two main functions to register keybindings (`keyCapture.initCaptures` and `keyCapture.onKeyPressed`) now return deregistering functions. This is important as we were introducing a memory leak (discovered by investigating #557) by adding lots and lots of callbacks to this service. When directives define keyBindings, they have to deregister their listeners when their scope is destroyed. The `Tree` is doing this now, as well as the dreaded `contextMenu`s - though they need to be reimplemented anyway, this at least closes one large issue with them immediately.

Other minor fix: `history` registers its keyCaptures at the right time now.

Documentation headers for `keyCapture` have been added, but still need to be filled out. Will come in a subsequent PR.