Avoid referencing the wrong keypath index during eventhandler rebinds

The callback is created with a capture on `i`, which is then incremented at the end of the loop. So, when the callback is called, `i` is now `i++` and weird things happen in the `EventHandler.keypaths`.

My javascript-fu is a little weak here. Is this the best way to handle this sort of thing?

Fixes #1545